How to insert time in SQl Server 2005?

I am creating a windows application. In this I have to subtract two dates. I subtract it successfully, I used TimeSpan to get the subtracted value. But when I insert it into SQl Server 2005 db, it is inserted with start date i.e. 1/1/1900 and estimated difference

What format should I use to insert only time?

Thanks in advance

+2


a source to share


2 answers


sql date format for yyyy-mm-dd hh:mm:ss

example:2010-05-07 09:59:59



+1


a source


If you only insert time, it will be interpreted as time past midnight 1/1900. Maybe you can convert the time interval to seconds (. TotalSeconds

Maybe?) And then store that as INT to get what you are looking for.



+1


a source







All Articles