Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Return GETDATE() in MON YYYY format

Author  Topic 

Windza
Yak Posting Veteran

61 Posts

Posted - 2008-09-23 : 00:36:03
Any quick tips on how to have a datetime field return as MON YYYY...
Cheers...

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-23 : 00:46:58
This is a presentation issue and can be best dealt with at your front end application. However if you want to do this in sql, use

SELECT SUBSTRING(CONVERT(varchar(10),datefield,106),4,6)
Go to Top of Page

Windza
Yak Posting Veteran

61 Posts

Posted - 2008-09-23 : 00:58:40
Cheers Visakh16...

Your SUBSTRING(CONVERT(varchar(12),GETDATE(),106),4,6)
Returned: Sep 20

SUBSTRING(CONVERT(varchar(12),GETDATE(),113),4,8)
Returned correctly: Sep 2008

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-23 : 01:02:17
quote:
Originally posted by Windza

Cheers Visakh16...

Your SUBSTRING(CONVERT(varchar(12),GETDATE(),106),4,6)
Returned: Sep 20

SUBSTRING(CONVERT(varchar(12),GETDATE(),113),4,8)
Returned correctly: Sep 2008




just forgot that it returns year in century
Go to Top of Page
   

- Advertisement -