August 21, 2017 at 2:13 am
Im developing a web app in azure and we have an instance of sql server hosted in a VM in an azure environment located in western europe. The system time of sql server is currently 1 hour behind my local development machine because we are currently in british summer time in the uk. Im developing a schedule module which uses dates & times. These are entered though clients browsers in the UK (we only have uk clients) so any time data is currently 1 hour ahead. Ive created a function which detects bst, it work fine. But I dont need this functionality if Im testing locally, so I want a switch in my sql which will ignore the bst function if the locale of sql server (my development machine) is in the uk. How can I detect the locale programmatically ? some thing like
IF locale != UK THEN
bst check here
August 21, 2017 at 2:25 am
SQL isn't run on the client side, so you can't "check" the timezone of the client in there. You'd need to check the client's date/timezone some other way and pass it in your SQL.
You could, instead, use datetimeoffset, if you're in a multi timezone environment. This stores the UTC settings as part of the time instead. For example:SELECT SYSDATETIMEOFFSET();
--Returns 2017-08-21 09:24:15.2435981 +01:00
The +01:00 here represents the BST, as I am also in the UK.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
August 24, 2017 at 11:14 am
How about using a dll kind a component that can be called from SQL server and getting the datetime from client as a return value.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy