Subject | Re: [firebird-support] SQL error conversion from string |
---|---|
Author | Ann W. Harrison |
Post date | 2005-05-24T17:40:50Z |
Peter Ypenburg wrote:
If you could look at the physical representation of the date in
Firebird, you'd find it was the number of days since November 17, 1858.
(That's a long story, check the archives.)
Which definition of "Julian date" are you using? The US Naval
Observatory translates today as 2,453,515. According to their site,
"Julian dates (abbreviated JD) are simply a continuous count of days and
fractions since noon Universal Time on January 1, 4713 BCE (on the
Julian calendar)." My guess is that that you're using a variant of
Julian that's the number of days since January 1, 1900 (or maybe
December 30, 1899, there seems to be a discrepancy).
Anyway, the answer to your question is - don't cast, compute by
subtracting your base date from whatever you want to convert to "Julian".
select (cast('05/24/2005' as date) - cast('12/30/1899' as date)) from
Regards,
Ann
>Hmmm. I guess "that's not the way it works" isn't a good enough answer.
> select cast(cast('05/24/2005' as date) as int)
> from RDB$DATABASE
>
> I am trying to get the Julian date from a date string '05/24/2005' which is
> 38496.
>
If you could look at the physical representation of the date in
Firebird, you'd find it was the number of days since November 17, 1858.
(That's a long story, check the archives.)
Which definition of "Julian date" are you using? The US Naval
Observatory translates today as 2,453,515. According to their site,
"Julian dates (abbreviated JD) are simply a continuous count of days and
fractions since noon Universal Time on January 1, 4713 BCE (on the
Julian calendar)." My guess is that that you're using a variant of
Julian that's the number of days since January 1, 1900 (or maybe
December 30, 1899, there seems to be a discrepancy).
Anyway, the answer to your question is - don't cast, compute by
subtracting your base date from whatever you want to convert to "Julian".
select (cast('05/24/2005' as date) - cast('12/30/1899' as date)) from
Regards,
Ann