-
October 8th, 2020, 10:18 AM
#1
SQL Server - date conversion
Hi,
Select CONVERT(datetime, 0xffff2e4600000000)
This SQL request does not give the correct date when running on my SQL server's installation.
It gives for instance : 1753-01-01 00:00:00.000
How can I fix it ?
Thank you for help
-
October 8th, 2020, 12:54 PM
#2
Re: SQL Server - date conversion
-
October 8th, 2020, 01:19 PM
#3
Re: SQL Server - date conversion
Originally Posted by Arjay
Quote it
Do you mean something like this : Select CONVERT(datetime, '0xffff2e4600000000') ?
If so, it does not work. It gives an error ==> Échec de la conversion de la date et/ou de l'heure Ã* partir d'une chaîne de caractères.
-
October 8th, 2020, 02:31 PM
#4
Re: SQL Server - date conversion
Originally Posted by James West
Do you mean something like this : Select CONVERT(datetime, '0xffff2e4600000000') ?
If so, it does not work. It gives an error ==> Échec de la conversion de la date et/ou de l'heure Ã* partir d'une chaîne de caractères.
The error message 9translated to English) means "Failed to convert date and / or time from a string".
Do you try to convert from hex data rather than a "string"?
Victor Nijegorodov
-
October 8th, 2020, 02:36 PM
#5
Re: SQL Server - date conversion
Originally Posted by James West
Hi,
Select CONVERT(datetime, 0xffff2e4600000000)
This SQL request does not give the correct date when running on my SQL server's installation.
It gives for instance : 1753-01-01 00:00:00.000
How can I fix it ?
Thank you for help
Again: what result do you expect and where comes this magic value 0xffff2e4600000000 from?
Victor Nijegorodov
-
October 8th, 2020, 02:46 PM
#6
Re: SQL Server - date conversion
I am expecting to get a recent date like 2019-09-xx or something in 2020 not for two or three century less
-
October 8th, 2020, 02:52 PM
#7
Re: SQL Server - date conversion
Originally Posted by James West
I am expecting to get a recent date like 2019-09-xx or something in 2020 not for two or three century less
Then where does this magic value 0xffff2e4600000000 come from?
Victor Nijegorodov
-
October 8th, 2020, 03:07 PM
#8
Re: SQL Server - date conversion
Originally Posted by James West
I am expecting to get a recent date like 2019-09-xx or something in 2020 not for two or three century less
In such a case the hex (or binary) you would convert from should be look like (according to my SSMS 2014)
0x323031392D30392D33300000000000000000000000000000000000000000 (for the date '2020-09-30')
Victor Nijegorodov
-
October 8th, 2020, 03:15 PM
#9
Re: SQL Server - date conversion
Very interesting !
I will check in this way.
Could you explain more ?
-
October 8th, 2020, 03:20 PM
#10
Re: SQL Server - date conversion
Originally Posted by James West
Could you explain more ?
What "more"?
I just read the MSDN (docs.microsoft.com)
Victor Nijegorodov
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|