Solved

Convert Datetime To UTC

Posted on 2009-07-03
4
553 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
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 41

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 41

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now