Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get number of seconds between 01/01/1970 and 12/31/2050

Status
Not open for further replies.

RileyCat

Programmer
Apr 5, 2004
124
US
The result of datediff(ss, '01/01/1970', '12/31/2050') is a bigint so "datediff" is overflowing.

How can I get from a bigint value to its equivalent date and back again if the max a date can be in SQL is "int"???

I need to be able to store number of seconds between '01/01/1970' and '12/31/2050' in SQL but convert that value to its calendar date for display in a web page.

Any ideas would be appreciated.

Thank you!

Stay Cool Ya'll! [smile2]

-- Kristin
 
Code:
datediff(d, '01/01/1970', '12/31/2050')*convert(bigint,86400)
that is how many days time scondes in a day
 

Don't forget datediff counts the number of midnights between the 2 dates so if you want the number of seconds between 01/01/1970 00:00:00 and 12/31/2050 23:59:59 you need to add 1 to the datediff figure before you multiply if by 86400.


I love deadlines. I like the whooshing sound they make as they fly by
Douglas Adams
(1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top