Re: Julian Date
Posted in 1997
On 16 Dec 1997, Bloomberg L.P wrote:
> As a very new user of Informix, I have no idea if there are standard
> commands in Informix that can give me the current date in Julian Date
> Format (YYYYDDD).
No, not as standard. However, it is not very hard to devise a stored
procedure which will do the job:
CREATE PROCEDURE julian_date(d DATE) RETURNING INTEGER; RETURN (YEAR(d) * 1000) + (d - MDY(1, 1, YEAR(d))) + 1;
END PROCEDURE;
Given that today is 16th December 1997, running the following yields the
answers 1997350 and 1998001 (and selecting TODAY+16 yields 01/01/1998):
SELECT julian_date(TODAY) FROM SysTables WHERE Tabid = 1;
SELECT julian_date(TODAY+16) FROM SysTables WHERE Tabid = 1;
In point of detail, you can write the expression in the SP inline anywhere
you wish to do so, so you do not have to use an SP. But I humbly suggest
that it is easier to understand the SELECT if the SP is used.
Yours,
Jonathan Leffler (johnl@informix.com) #include <witticism.h>