Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My Asp.Net c# application stores date in database [sql server 2014] as OA date [as float]. and when i tried to convert the date in db into date (103) format, the result date differ from the original date i stored.

I used the following query:

"SELECT CAST((CONVERT(float,[DateColumn])) as datetime) AS [Date] FROM MyTable"

How should i resolve this?
Posted

1 solution

OADATE uses a different base date to SQL (I strongly recommend that you move over to Date or Datetime if possible). There is a two day difference. Try the following
select DATEADD(dd, -2, CAST([DateColumn] as datetime)) AS [Date] FROM MyTable
 
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