What's the point??

  • ....in having a "mm" in the datepart function if it only returns "m"?? And the same goes for "dd"

    For instance if I select datepart(mm, duedate) and duedate is 10/5/03 then the statement returns 5 instead of 05!

    So now what?? I have to write a case statement checking the lenth of the datepart and if it equals 1 append the 0....boy that sucks.

    Hope there's a more efficent way of doing this than having to code around what the datepart function returns?

    Any ideas?

    Thanks in advance

  • My requirements are this...

    I'm writing a "simple" select statement that returns the date in this format yyymmdd so I have this

    select convert(varchar,datepart(yyyy,duedate)) + convert(varchar,datepart(mm,duedate)) + convert(varchar,datepart(dd,duedate)) from ....

    but with a date like 1/5/03 I get 200315 instead of 20030105

    This no longer becomes a "simple" select if I have to write a Case statement for each possible case

  • select convert(varchar,duedate,112)

  • I knew I'd find the answer here.. Thanks..I didn't think to look at the convert statement

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply