Date Format

  • 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.

  • "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?)

  • 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