Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Convert variant date (FLOAT) to datetime

I have a table that contains FLOAT field from datetime. When I convert this values to datetime, there is a two days difference between converted date with correct date. For example:

enter image description here

But in this site date convert is correct!!!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

In this post, explains why this happens, but what is the solution in SQL Server?

>Solution :

You need to construct the datetime value from the correct "zero" date:

SELECT DATEADD(day, 45099, CONVERT(date, '18991230'))

Your current statement uses implicit data type conversion and adds number of days to the default datetime value 1900-01-01.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading