Reputation: 21
I am creating windows application .In this I have to subtract two dates .I subtract it successfully ,I used TimeSpan to get subtracted value.But when I insert it in SQl Server 2005 db, it inserted with starting date i.e. 1/1/1900 and the calculated difference
which format should I use to insert Time only?
Thanks in advance
Upvotes: 2
Views: 2123
Reputation: 33914
If you insert just the timespan, it will be interpreted as the time past midnight on 1/1/1900. Perhaps you can convert the timespan to seconds (.TotalSeconds
, maybe?) and then store that as an INT to get what you're looking for.
Upvotes: 1
Reputation: 9668
sql date format is yyyy-mm-dd hh:mm:ss
for example: 2010-05-07 09:59:59
Upvotes: 1