Getdate() Formatting
By MichaelDeputy, 1 year and 8 months ago
I get the occasional question from our Oracle DBAs on how do you do this in MSSQL. Usually I have little to no idea, so I do what all new DBAs do: Look it up. Well, this situation came up today on how can I write a procedure that will query the table and give me all the enteries for today. The column the date is stored in is varchar in this format 11/14/2008. I found the answer is select convert(varchar,getdate(),101) So I thought I'd add the sytle ID numbers for future reference.
|
Style ID |
Style Type |
|---|---|
| 0 or 100 | mon dd yyyy hh:miAM (or PM) |
| 101 | mm/dd/yyyy |
| 102 | yyyy.mm.dd |
| 103 | dd/mm/yyyy |
| 104 | dd.mm.yyyy |
| 105 | dd-mm-yyyy |
| 106 | dd mon yyyy |
| 107 | Mon dd, yyyy |
| 108 | hh:mm:ss |
| 9 or 109 | mon dd yyyy hh:mi:ss:mmmAM (or PM) |
| 110 | mm-dd-yyyy |
| 111 | yyyy/mm/dd |
| 112 | yyyymmdd |
| 13 or 113 | dd mon yyyy hh:mm:ss:mmm(24h) |
| 114 | hh:mi:ss:mmm(24h) |
| 20 or 120 | yyyy-mm-dd hh:mi:ss(24h) |
| 21 or 121 | yyyy-mm-dd hh:mi:ss.mmm(24h) |
| 126 | yyyy-mm-dd Thh:mm:ss.mmm(no spaces) |
| 130 | dd mon yyyy hh:mi:ss:mmmAM |
| 131 | dd/mm/yyyy hh:mi:ss:mmmAM |
.
.
.
No comments
Be the first to write a comment on this post.
Write a comment
If you want to add your comment on this post, simply fill out the next form:
* Required fields
You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>.
No trackbacks
To notify a mention on this post in your blog, enable automated notification (Options > Discussion in WordPress) or specify this trackback url: http://www.deputyfamily.net/MichaelDeputy/archive/2008/12/getdate-formatting/trackback/