SQL Server Epoch Converter
Convert Unix epoch timestamps to SQL Server datetime2 values and back, then copy the DATEADD() and DATEDIFF_BIG() queries for your value.
Client-side only, nothing leaves your browser
Auto-detected: seconds · 3.7y ago
Conversions
SQL Server SQL
SELECT DATEADD(second, 1679616000, CAST('1970-01-01' AS datetime2));SELECT DATEADD(millisecond, 0, DATEADD(second, 0, DATEADD(day, 19440, CAST('1970-01-01' AS datetime2(3)))));SELECT DATEADD(second, 1679616000, CAST('1970-01-01' AS datetime2)) AT TIME ZONE 'UTC' AT TIME ZONE 'Eastern Standard Time';SELECT CONVERT(varchar(19), DATEADD(second, 1679616000, CAST('1970-01-01' AS datetime2)), 120);SQL Server Epoch & Unix Timestamps
SQL Server has no FROM_UNIXTIME() or UNIX_TIMESTAMP(). To get a date, add the epoch seconds to 1970-01-01 with DATEADD(). To get an epoch, count the seconds from 1970-01-01 with DATEDIFF(), or DATEDIFF_BIG() when the number won't fit in an int. Through SQL Server 2022, the number you pass to DATEADD() must fit in an int, so a millisecond epoch has to be split into seconds and a remainder. SQL Server 2025 accepts a bigint. The result is UTC with no offset attached, and AT TIME ZONE converts it to a local zone.
Quick Reference
- DATEADD(second, epoch, '1970-01-01'): Epoch seconds to a datetime
- DATEDIFF(second, '1970-01-01', dt): Datetime to epoch seconds as an int
- DATEDIFF_BIG(millisecond, '1970-01-01', dt): Datetime to epoch milliseconds as a bigint
- AT TIME ZONE 'zone': Attach or convert a time zone, using Windows zone names
- SYSUTCDATETIME(): Current UTC date and time as datetime2
Notable Epoch Values
| Event | Epoch (seconds) | Date |
|---|---|---|
| Unix Epoch | 0 | January 1, 1970 00:00:00 UTC |
| 1 Billion | 1000000000 | September 9, 2001 01:46:40 UTC |
| Y2K38 (32-bit limit) | 2147483647 | January 19, 2038 03:14:07 UTC |
| 2 Billion | 2000000000 | May 18, 2033 03:33:20 UTC |
| Current (approx) | ~1774000000 | March 2026 |
Frequently asked questions
What is timestamp in SQL Server?
Is there a FROM_UNIXTIME function in SQL Server?
How do I get the current Unix timestamp in SQL Server?
How do I convert a Unix timestamp in milliseconds to datetime in SQL Server?
How do I convert a datetime to epoch milliseconds in SQL Server?
Want 1bench for SQL Server?
1bench doesn't connect to SQL Server yet. Ask for it and we'll let you know as soon as early access opens.
Request Early Access