I have the following C# method to get current unix epoch time stamp,
public static long GetCurrentUnixTimestampSeconds()
{
var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return (long)(DateTime.UtcNow - unixEpoch).TotalSeconds;
}
I need the same in SQL Server. Is it possible?
This is just the number of seconds between epoch and current UTC time:
SELECT DATEDIFF(SECOND, '19700101', sysutcdatetime());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With