Solved

Convert Datetime To UTC

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

746 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

10 Experts available now in Live!

Get 1:1 Help Now