August 2, 2016 at 12:13 am
Good morning 🙂
I have a table that if you dont add the date, by defult it will add the date.
create table Raw_Data
(
ID int identity primary key
,DateCreated datetime NOT NULL DEFAULT(GETDATE())
,RequestNumber int
,Amount float
the problem is that my db is in gmt time and I am gmt +3
I cannot change the server time.
how do i save the correct time?
August 2, 2016 at 12:15 am
I know the dateadd(HOUR, 3, getdate()) :-D:-D:-D
but is that the correct when you add dates automatically ?
August 2, 2016 at 1:42 am
astrid 69000 (8/2/2016)
Good morning 🙂I have a table that if you dont add the date, by defult it will add the date.
create table Raw_Data
(
ID int identity primary key
,DateCreated datetime NOT NULL DEFAULT(GETDATE())
,RequestNumber int
,Amount float
the problem is that my db is in gmt time and I am gmt +3
I cannot change the server time.
how do i save the correct time?
First suggestion would be changing the datetime to a time zone aware datatype like DATETIMEOFFSET or DATETIME2 and work from there, DATETIME has no time zone awareness so it's always on UTC in a way.
😎
August 2, 2016 at 3:52 am
thanks!!!
August 2, 2016 at 6:01 am
Since your server is already on UTC time, they're essentially one in the same.
That said, I like the DATETIME data type. You can use the GETDATE() or GETUTCDATE() function. They do what their name implies. In your case, they should return the same values.
SELECT GETDATE(), GETUTCDATE();
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply