Skip to content

Change Tracking Version to Date Time

A query that converts change tracking commit versions from sys.dm_tran_commit_table into local time.

Published Sep 6, 2006

Change tracking reports changes by version number, but humans think in clock time. This query reads the commit table behind change tracking and converts each commit's UTC timestamp into your local timezone using SWITCHOFFSET with the current system offset - so you can correlate a SYS_CHANGE_VERSION against an actual wall-clock moment.

SELECT
	commit_ts,
	xdes_id,
	commit_lbn,
	commit_csn,
	commit_time as commit_time_utc,
	CONVERT(DateTime, 
		SWITCHOFFSET(CONVERT(DateTimeOffset, commit_time),
		DATENAME(TzOffset, SYSDATETIMEOFFSET()))
	) as commit_time_local
FROM
	sys.dm_tran_commit_table
An unhandled error has occurred. Reload 🗙