Skip to content

Instantly share code, notes, and snippets.

@tdmitch
Created October 10, 2017 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdmitch/35b7c1d578a4f7e183d07959d6f18adc to your computer and use it in GitHub Desktop.
Save tdmitch/35b7c1d578a4f7e183d07959d6f18adc to your computer and use it in GitHub Desktop.
/* Get local time */
DECLARE @dt2 DATETIMEOFFSET = GETDATE() AT TIME ZONE 'Central Standard Time'
/* Convert to UTC */
SET @dt2 = @dt2 AT TIME ZONE 'UTC';
/* Now query the table using the offset datetime2 */
SELECT ValidFrom, ValidTo, * FROM dbo.Customers
FOR SYSTEM_TIME AS OF @dt2
WHERE (address = '' OR customerid = 13)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment