To convert the current machine date and time to a varchar in the format YYYY-MM-DDThh:mm:ss[+|-]hh:mm in T-SQL, you can use the following code:

 

select convert(varchar(100), cast(sysdatetimeoffset() as datetimeoffset(0)), 126)

 

Result (in Amsterdam in Summer time)

2012-08-13T15:23:09+02:00

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.