vision59
SSCrazy
Points: 2601
More actions
November 14, 2009 at 12:02 pm
#140031
I am grouping the data by Month and Year in sql. Using that I am getting as Date CONVERT ( CHAR(6),i_date, 112 ). This is giving me 200806. I want it in the format 06/2008. Is there any way to do it.
Florian Reischl
SSC-Dedicated
Points: 37301
November 14, 2009 at 1:59 pm
#1079406
"i_date" smells like an integer, right?
Try this:
SELECT SUBSTRING(CONVERT(VARCHAR(12), CONVERT(DATETIME, CONVERT(CHAR(6),i_date) + '01'), 103), 4, 7)
Greets
Flo
(PS: What's wrong with storing dates as DATETIME those days on SSC?)
Lynn Pettis
SSC Guru
Points: 442467
November 14, 2009 at 6:57 pm
#1079429
Old COBOL programmers who can't learn new tricks? 😉
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply