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)


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.