In my SQL Server database, I have a datetime
column.
What is a good way to create a new column that represents the long
value for the datetime
column? The long
would represent a number of seconds.
I thought if I can convert it to longs
, it would make it easier to do group by queries over time periods, as I could just divide the long number by fixed amounts.
The table is static, Won't be updating or deleting data.
Best Answer
Create a new column (ALTER TABLE) then run an UPDATE on it
19000101
is the SQL Server epoch. You can use19700101
for Unix epoch for example