sam
sam

Reputation: 21

How to insert time in SQl Server 2005?

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

Answers (2)

SqlRyan
SqlRyan

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

x2.
x2.

Reputation: 9668

sql date format is yyyy-mm-dd hh:mm:ss for example: 2010-05-07 09:59:59

Upvotes: 1

Related Questions