| Author |
Topic  |
|
|
sonu
Posting Yak Master
110 Posts |
Posted - 01/11/2010 : 15:58:36
|
Hi, I am using the below sql to convert the local datetime to the local time in Frankfurt, which is UTC+1.
DECLARE @LocalDate DATETIME, @UTCDate DATETIME SET @LocalDate = GetDate() -- convert local date to utc date SET @UTCDate = DATEADD(Hour, DATEDIFF(Hour, GETUTCDATE(), GetDate()), @LocalDate) print GetDate() print @UTCDate print DATEADD(HOUR, 1, @UTCDate)
Output:
Jan 11 2010 12:32PM Jan 11 2010 4:32AM Jan 11 2010 5:32AM
Now does this mean, that if its 12:32PM in LA, then its 5:32AM in Franfurt? That seems be incorrect though. It should be 9:32PM in Franfurt. I am confused.
Our server is sql 2005. The server is located in LA.
|
|
|
webfred
Flowing Fount of Yak Knowledge
Germany
8513 Posts |
Posted - 01/11/2010 : 16:09:40
|
LA = German time - 9 hours
No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
sonu
Posting Yak Master
110 Posts |
Posted - 01/11/2010 : 16:12:09
|
quote: Originally posted by webfred
LA = German time - 9 hours
I want the time in Franfurt, not LA. |
 |
|
|
Vinnie881
Flowing Fount of Yak Knowledge
USA
1202 Posts |
Posted - 01/11/2010 : 16:15:44
|
Declare @UTC datetime,@Frankfort datetime,@Central datetime, @Pacific datetime select @UTC = GETUTCDATE() ,@Frankfort = dateadd(hour,1,GETUTCDATE()) ,@Central = dateadd(hour,-6,GETUTCDATE()) ,@Pacific = dateadd(hour,-8,GETUTCDATE()) print @UTC print @Frankfort print @Central print @Pacific
Success is 10% Intelligence, 70% Determination, and 22% Stupidity. \_/ _/ _/\_/ _/\_/ _/ _/- 881 |
 |
|
|
webfred
Flowing Fount of Yak Knowledge
Germany
8513 Posts |
Posted - 01/11/2010 : 16:33:18
|
quote: Originally posted by sonu
quote: Originally posted by webfred
LA = German time - 9 hours
I want the time in Franfurt, not LA.
Frankfurt = LA + 9 hours
No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
vijayisonly
Flowing Fount of Yak Knowledge
USA
1836 Posts |
Posted - 01/11/2010 : 16:40:54
|
quote: Originally posted by sonu
Hi, I am using the below sql to convert the local datetime to the local time in Frankfurt, which is UTC+1.
DECLARE @LocalDate DATETIME, @UTCDate DATETIME SET @LocalDate = GetDate() -- convert local date to utc date SET @UTCDate = DATEADD(Hour, DATEDIFF(Hour, GETUTCDATE(), GetDate()), @LocalDate) print GetDate() print @UTCDate print DATEADD(HOUR, 1, @UTCDate)
Output:
Jan 11 2010 12:32PM Jan 11 2010 4:32AM Jan 11 2010 5:32AM
Now does this mean, that if its 12:32PM in LA, then its 5:32AM in Franfurt? That seems be incorrect though. It should be 9:32PM in Franfurt. I am confused.
Our server is sql 2005. The server is located in LA.
The problem with your query is..while calculating @UTCdate..it shud have been..
SET @UTCDate = DATEADD(Hour, DATEDIFF(Hour, GetDate(),GETUTCDATE()),@LocalDate) |
Edited by - vijayisonly on 01/11/2010 16:41:43 |
 |
|
|
canada goose jackets
Starting Member
4 Posts |
|
|
canada goose jackets
Starting Member
4 Posts |
|
|
canada goose jackets
Starting Member
4 Posts |
|
|
canada goose jackets
Starting Member
4 Posts |
|
| |
Topic  |
|