Reputation: 11
SQL server 2016
SELECT GETDATE() AS myTime
result: myTime: 2019-11-10 10:43: 15.873
I think this is US Eastern Time, however, I'm living in the West, how can I change this to US Pacific time. I want result 2019-11-10 7:43: 15.873
thank you for all answers, I tried to find Time Duration between Now and the past, that why I try to use GetDate() to get current date/time my setup like this:
Declare @past_time datetime = '2019-11-09 8:40'
Declare @current_time datetime
set @current_time = GetDate() at time zone 'Pacific Standard Time';
select @current_time - @past_time;
The answer I got still having 3 hours extra, I know the fact that SQL server is on the east coast and i'm on the west coast.
Upvotes: 0
Views: 2189
Reputation: 1297
GETDATE ()
basically gets the current system date-time, you probably got to check the server/system time zone where SQL server service is running that your querying to.
And you could convert into any zone as follows:
Declare @Datetime datetime = '2019-11-10 10:43';
select (@Datetime at time zone 'Pacific Standard Time')
For all time zone info
select * from sys.time_zone_info;
Upvotes: 2