Re: Julian date
Posted in 2005
Hope this helps: Converting Between INTEGER and DATE You can convert an integer column (SMALLINT, INTEGER, or INT8) to a DATE value. The database server interprets the integer as a value in the internal format of the DATE column. You can also convert a DATE column to an integer column. The database server stores the internal format of the DATE column as an integer representing a Julian date. Converting Between Julian Dates and Gregorian Calendar Dates The Julian date (JD) is a continuous count of days from 1 January 4713 BC (= -4712 January 1), Greenwich mean noon (= 12h UT). For example, AD 1978 January 1, 0h UT is JD 2443509.5 and AD 1978 July 21, 15h UT, is JD 2443711.125. Conversion of Gregorian calendar date to Julian date for years AD 1801-2099 can be carried out with the following formula: * JD = 367K - <(7(K+<(M+9)/12>))/4> + <(275M)/9> + I + 1721013.5 + UT/24 - 0.5sign(100K+M-190002.5) + 0.5* where K is the year (1801 <= K <= 2099), M is the month (1 <= M <= 12), I is the day of the month (1 <= I <= 31), and UT is the universal time in hours ("<=" means "less than or equal to"). The last two terms in the formula add up to zero for all dates after 1900 February 28, so these two terms can be omitted for subsequent dates. This formula makes use of the sign and truncation functions described below: The *sign* function serves to extract the algebraic sign from a number. Examples: sign(247) = 1; sign(-6.28) = -1. The *truncation* function < > extracts the integral part of a number. Examples: <17.835> = 17; <-3.14> = -3. *Example*: Compute the JD corresponding to 1877 August 11, 7h30m UT. Substituting K = 1877, M = 8, I = 11 and UT = 7.5, JD = 688859 - 3286 + 244 + 11 + 1721013.5 + 0.3125 + 0.5 + 0.5 = 2406842.8125 The formula given above was taken from the U.S. Naval Observatory's no-longer- published /Almanac for Computers/ for year 1990. Dirk Moolman wrote: >How do I display a date in Julian format in Informix ? > >(I think the version is 9.21, if this makes a difference - for a friend >of mine) > >Dirk Moolman >Database and Unix Administrator >MxO Information Systems (HealthCorp) > > > >"People demand freedom of speech as a compensation for the freedom of >thought which they seldom use." > > >sending to informix-list > > > -- Franz Gr'tzmacher DBA / Analyst Programmer (IT Dept) Bible Society of South Africa Tel: +27 21 4212040 ext 191 Fax: +27 21 4194846 http://www.biblesociety.co.za/ DISCLAIMER: The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. sending to informix-list