April 22, 2022 at 2:22 pm
SQL Server has no idea where the logged-in user is - TSQL is execute on the server, not the client.
If you want this information for SQL Server, you will have to pass it/set it in the query. SQL Server has CONTEXT_INFO() and, starting w/ 2016, the better SESSION_CONTEXT().
If you have an application, it can use the available location information to somewhat accurately, depending on the device/application, figure out where the user is. Otherwise, you probably need a user table for your users that includes their timezone.
April 22, 2022 at 7:09 pm
The application needs to pass the date/time as a datetimeoffset - but that won't provide you with the time zone. All that gives you is the offset for that client - and each offset can have multiple time zones defined (and some that will be the same at different times depending on when they switch to/from daylight savings time).
You can look in the table sys.timezone to see the list of available time zones and their current offset.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
Viewing 2 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply