Solved

Convert Datetime To UTC

Posted on 2009-07-03
4
559 Views
Last Modified: 2012-05-07
I want to convert an _arbitrary_ smalldatetime into its equivelent UTC.
I do not want to convert the current time to UTC.
(Not wanting to refer to the current time at all, that is why I believe the getUTCDate() function is not applicable.)

So, given: '9/22/2009 1:25:00 PM' I would expect an integer representing the UTC.

Cheers
0
Comment
Question by:silchester
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Rahul Goel ITIL
ID: 24771545
0
 

Author Comment

by:silchester
ID: 24771839
Hi

I have seen this, but the code does not return an integer representing the seconds since the UTC epoch.

still no success unfortunately
0
 
LVL 42

Expert Comment

by:pcelba
ID: 24772066
smalldatetime is counted from 01.01.1900 00:00 and it is rounded to minutes. To call it UTC epoch is not accurate. The number of seconds since smalldatetime beginning will cause numeric overflow when converted to int data type.

You should decide either to convert it to bigint or to calculate number of minutes instead of seconds.
0
 
LVL 42

Accepted Solution

by:
pcelba earned 500 total points
ID: 24772108
You could maybe look at http://en.wikipedia.org/wiki/Coordinated_Universal_Time and http://en.wikipedia.org/wiki/Unix_time and tell what exactly you need.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question