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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 formating a date

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2009-10-07 : 12:41:29
I have an integer field in my DB that has a date like "200812". I would like to do a select that brings back the values as "DEC 2008" Is this possible?

Dave
Helixpoint Web Development
http://www.helixpoint.com

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2009-10-07 : 12:47:14
[code]
select
case right(MyDate, 2)
when '01' then 'JAN'
when '02' then 'FEB'
when '03' then 'MAR'
when '04' then 'APR'
when '05' then 'MAY'
when '06' then 'JUN'
when '07' then 'JUL'
when '08' then 'AUG'
when '09' then 'SEP'
when '10' then 'OCT'
when '11' then 'NOV'
when '12' then 'DEC'
end + ' ' + left(MyDate, 4)
from MyTable
[/CODE]

=======================================
Few things are harder to put up with than the annoyance of a good example. (Mark Twain)
Go to Top of Page

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2009-10-07 : 12:54:06
This is an access database. Case does not seem to work

Dave
Helixpoint Web Development
http://www.helixpoint.com
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-08 : 04:27:30
quote:
Originally posted by helixpoint

This is an access database. Case does not seem to work

Dave
Helixpoint Web Development
http://www.helixpoint.com


Then why did you post in SQL Server 2005 forum?
Post your question at ACCESS forum

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -