Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,
i want to store date as number of seconds from 1/1/1980..How can i do this?


Please help me out...thanks in advance..
Posted
Updated 18-May-12 22:38pm
v2

Strange thing to do!
Still...
VB
Dim ts As TimeSpan = DateTime.Now - New DateTime(1980, 1, 1)
Dim seconds As Double = ts.TotalSeconds
 
Share this answer
 
Comments
Maciej Los 19-May-12 6:22am    
Good answer, my 5!
If you're storing the data in a database (based on your question title), I would strongly advice not to do that.

Instead store the date using a datetime column. You can always calculate the difference to a specific date using DATEDIFF[^]
 
Share this answer
 
Comments
Maciej Los 19-May-12 6:22am    
Good answer, my 5!
Wendelius 19-May-12 6:34am    
Thanks :)
Do not do such nonsense! Use the Date / DateTime datatype of your database instead.
See also http://thedailywtf.com/Articles/Epoch-Billing-System.aspx[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900