Solved

Convert Datetime To UTC

Posted on 2009-07-03
4
560 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

729 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