Subject Re: [firebird-support] SQL error conversion from string
Author Ann W. Harrison
Peter Ypenburg wrote:
>
> 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.
>

Hmmm. I guess "that's not the way it works" isn't a good enough answer.
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