-
to subtract dates, because the operation is not atomic, and you will on occasion get indeterminate results due to race conditions between the system datetime and the local datetime being checked at different times (i.e., non-atomically).GetDate()-GetUTCDate
only gives you the offset today at the server's TZ, which is not relevant.@@Version
>= SQL Server 2016 users, Below is a simple function using AT TIME ZONE
.@LocalTimeZone
can take, please go to this link or Go to KEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionTime Zones
Result:
2018-10-28 00:00