FOR SYSTEM_TIME BETWEEN ... AND
FOR SYSTEM_TIME BETWEEN..AND: like FROM..TO but includes rows starting at the upper bound
What changes
- Input
- temporal table current + history
- Output or change
- rows matching the period rule
Syntax at a glance
table FOR SYSTEM_TIME BETWEEN <start_date_time> AND <end_date_time>
Work example
An audit query needs FOR SYSTEM_TIME BETWEEN ... AND to answer a time-bounded question about a temporal table.
Use explicit UTC timestamps and test both ends of the interval. Confirm the table is system-versioned before relying on history.
Check your work FOR SYSTEM_TIME BETWEEN ... AND. The rows from FOR SYSTEM_TIME BETWEEN ... AND match the requested time boundary and current rows are not confused with history rows.
Open Microsoft Learn for full syntax, permissions, and details for your version.