|
Is there a code to get the date format yyyyddmm using the convert function i.e, SELECT CONVERT(varchar,GETDATE(), desired format here ) Thanks!
(comments are locked)
|
|
For YYYYDDMM you won't have much help from CONVERT. You can get YYYYMMDD. To use the fewest number of function calls, I'd go for: Out of curiuosity: Why do you want it on YYYYDDMM format? Now that's the big question...
Mar 10 '11 at 06:52 AM
ThomasRushton ♦
I know, it was set by the creators of the database I'm working on which also is barely normalised.
Mar 10 '11 at 07:13 AM
tabularyee
You have my profound sympathies.
Mar 10 '11 at 01:11 PM
ThomasRushton ♦
(comments are locked)
|
In response to @Mrs_Fatherjack's attempt using
(comments are locked)
|
|
or you could just use
d'oh. comes of me not reading the documentation properly...
Mar 10 '11 at 06:51 AM
ThomasRushton ♦
and I didn't read the question properly that brings back YYYYMMDD
Mar 10 '11 at 06:59 AM
Mrs_Fatherjack
...that too. I'm not having a good day today.
Mar 10 '11 at 07:01 AM
ThomasRushton ♦
(comments are locked)
|
|
Would this do it? I already tried something very similar... datepart(dd...) and datepart(mm...) lie, and only return 1 character if they can get away with it. At least they do on SQL 2005...
Mar 10 '11 at 07:05 AM
ThomasRushton ♦
No, unfortunately not. It would give you YYYYDM for January 1st, but YYYYDDMM for December 31st. I think my suggested solution is the one with the least number of function calls possible. But if it's the most effective solution, that I don't know - it depends on how effective different string manipulation functions and date functions are.
Mar 10 '11 at 07:05 AM
Magnus Ahlkvist
damn, that's not good then.
Mar 10 '11 at 07:06 AM
Mrs_Fatherjack
(comments are locked)
|


Why do you want the date in yyyyddmm format? or is that a typo?