Thursday, October 20, 2011

Date formatting

I always feel like I'm digging around to find a list of date formats and what their outputs look like, so I've included a list below.  I'm not going to discuss how each format breaks down the date, but I've included the formatting code along with the output.  I may have missed a few, but the majority I have used in the past are listed below.

format codeoutput
default2011-10-20 06:59:22.590
convert(varchar,getDate(),100)Oct 20 2011 6:59AM
convert(varchar,getDate(),101)10/20/2011
convert(varchar,getDate(),102)2011.10.20
convert(varchar,getDate(),103)20/10/2011
convert(varchar,getDate(),104)20.10.2011
convert(varchar,getDate(),105)20-10-2011
convert(varchar,getDate(),106)20 Oct 2011
convert(varchar,getDate(),107)Oct 20, 2011
convert(varchar,getDate(),108)06:59:00
convert(varchar,getDate(),109)Oct 20 2011 6:59:00:553AM
convert(varchar,getDate(),110)10-20-2011
convert(varchar,getDate(),111)2011/10/20
convert(varchar,getDate(),112)20111020
convert(varchar,getDate(),113)20 Oct 2011 06:59:00:553
convert(varchar,getDate(),114)06:59:00:553
convert(varchar,getDate(),120)2011-10-20 06:59:00
convert(varchar,getDate(),121)2011-10-20 06:59:00.553
convert(varchar,getDate(),126)2011-10-20T06:59:00.553
convert(varchar,getDate(),127)2011-10-20T06:59:00.553
convert(varchar,getDate(),130)23 ?? ?????? 1432 6:59:00:553
convert(varchar,getDate(),131)23/11/1432 6:59:00:553AM

No comments:

Post a Comment