Since SQL Server 2016 it is possible to automatically create Temporal Tables. I wanted to create a simple query that retrieves the data from a specified date. However, when I try to specify a date in the query like so, it gives a syntax error:
SELECT * FROM Person FOR SYSTEM_TIME AS OF GETDATE()
I even tried to convert the datatype to a datetime2, since the dates a stored like that, but it still wouldn't work:
SELECT * FROM Person FOR SYSTEM_TIME AS OF CONVERT(datetime2,GETDATE())
This problem occurrs, but when I first execute SELECT GETDATE()
and then copy the text and paste it into the query, it works fine.
How can I specify a datetime with the AS OF keyword?
Thanks in advance.