Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
lauramayer
Posting Yak Master
152 Posts |
Posted - 2011-06-15 : 15:25:44
|
| Good afternoon,I need to format the date time into "Full ISO format" like so: CCYY-MM-DDTHH:MM:SS.ssssssI tried CONVERT(VARCHAR(23), GETDATE(), 126) but that only gives me: 2011-06-15T15:25:19.243Can someone tell me what I need to do?ThanksLaura |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-06-15 : 15:32:19
|
| GETDATE()'s resolution is milliseconds, use SYSDATETIME() to return smaller increments. |
 |
|
|
lauramayer
Posting Yak Master
152 Posts |
Posted - 2011-06-15 : 15:45:03
|
| Thanks for that. That doesn't do it for me though. I get this when I replace getdate() with SYSDATETIME() and that got me basically the same thing. I got a little closer by doing this: CAST(GETDATE() AS datetimeoffset(6)) AS 'datetimeoffset'That give me : 2011-06-15 15:40:19.243000 +00:00 which is the closest I've come but how to get the "T" in there. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-06-15 : 15:46:28
|
| CONVERT(char(26), SYSDATETIME(), 126) |
 |
|
|
lauramayer
Posting Yak Master
152 Posts |
Posted - 2011-06-15 : 16:03:05
|
| Fantastic! Thanks so much. |
 |
|
|
|
|
|