sql - Datetime pattern for yyyy.mm.dd.hh.mm.ss pattern code? -
What is the DATE format code for "yyyy.mm.dd.h.h.mm.ss"?
I know that 34 (date format code) is "Yyamgagdhams", but what is the code for "yyyy.mm.dd.hh.mm.ss"?
It is on SQL 2005.
As GBN said, using one of the existing formats will work with some string combinations Another option is:
Cast Cast (Charge (Year 4) (4)) + '.' + Wright ('0' + Cast (Month (My_date) as VARCHAR (2)), 2) + '.' + Correct ('0' + cast (day (My_date) as VARCHAR (2)), 2) + '.' + Wright ('0' + Cast (DATEPART (HOOR, my_date) VARCHAR (2)), 2) + '.' + Wright ('0' + Cast (DATEPART (minute, my_date) VARCHAR (2)), 2) + '.' + Wright ('0' + cast (DATEPART (second, my_date) VARCHAR (2)), 2)
Comments
Post a Comment