0

I have a date formatted as follows:

00:50:34 Jun 25, 2017 PDT

.. actually I have it in this format

00%3A50%3A34+Jun+25%2C+2017+PDT

but can easily transform in the above.

I was wondering if there's a quick and simple way to transform it in a date I can use in a datediff function like

set nsDiff = datediff(ns,thisstrangedateformat,sysdatetime())
  • Check DATETIMEOFSET docs.microsoft.com/en-us/sql/t-sql/data-types/… – Alex Jul 7 '17 at 10:59
  • I think time zone if varying needs to be put to SQL Server as an offset of +HH:MM or -HH:MM (MM varies too). And at daylight saving, whatever you do will be wrong. If you need to build a lookup table of time zones then you may as well for month names too - then use date convert format 127 here docs.microsoft.com/en-us/sql/t-sql/functions/… where the input is 2006-12-12T23:45:12-08:00 i.e. yyyy-mm-dd T HH:MI:SS(.000)+-ZZ:ZZ If you don't need timezone and seconds then you can use format 100 which knows month names; then you can add seconds separately. – Robert Carnegie Jul 7 '17 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.