Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
Your profile
Tag cloud
book bug business intelligence database dates dmv functions gemini gotcha how to howto indexing interview madison performance performance tuning postgresql programming sql sql friday sql server sql server 2000 sql server 2005 sql server 2008 sql server 2008 r2 sqlserver t-sql tip trick xml
Authors
- SQLDenis (166)

- onpnt (86)

- George Mastros (32)

- chrissie1 (8)

- naomi (7)

- emtucifor (6)

- Alex Ullrich (6)

- thirster42 (4)

- ramireddyindia (2)

- riverguy (1)

- tarwn (1)

- pmch22 (1)

- More...
Main Categories
Search
Google Ads
Tags: datetime
I answered this question today and thought it would be useful to create a little post
If you have a varchar value like this '2009-06-26 14:30:00.000Z+4:30' you want to take 4 hours and 30 minutes and then subtract that from the date itself so in this case you will get 2009-06-26 11:00:00.000. The reason you subtract is because the +4:30 means that this was generated in a zone that is 4:30 ahead of utc
So first we need to figure out a couple of things
1) where are the minutes?
2) where is the hour?
3) is it positive or negative?
Here are the answers
I answered this question a while back and decided to create a little blogpost.
Let's say you have the following datetime values
2009-05-12 11:13:19.667
2009-05-12 11:12:19.667
2009-05-12 11:33:19.667
2009-05-12 11:43:19.667
2009-05-12 11:03:19.667
2009-05-12 11:53:19.667
2009-05-12 11:53:19.667
2009-05-12 11:23:19.667
2009-05-12 12:13:19.667
2009-05-12 12:12:19.667
2009-05-12 13:33:19.667
2009-05-12 13:43:19.667
2009-05-12 14:03:19.667
2009-05-12 14:53:19.667
2009-05-12 15:53:19.667
200...


LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.