Further to my HELP WITH JULIAN DATES posting, I know how to do the
DATETIME() substraction to get a Julian date using ISQL, but the trouble I'm
having is how do you do it within a 4GL program (i.e. using variables to
hold the dates). Any help would be greatly appreciated. Thanx.
------_=_NextPart_001_01C2B82C.E5111910
Content-Type: text/plain;
charset="ISO-8859-1"
You can try this function.
DEFINE jul_day CHAR(3) # Julian Date
define juliand CHAR(3)
LET jul_day = tojulian(today) #Format DDD
call tojulian(today) returning juliand
function tojulian(in_date)
define
in_date date,
jul_val char(4),
date_c char(10),
date_d date,
number_days integer,
jul_days char(3)
if in_date is null
then
initialize jul_val to null
else
# calc last day of last year in char format
let date_c[1,6] = "12/31/"
let date_c[7,10] = year(in_date) - 1
# convert to date format
let date_d = date(date_c)
# number of days in current year
let nnumber_days = in_date - date_d
let jul_days = number_days using "&&&"
end if
return jul_val
end function
Hello,
------_=_NextPart_001_01C2B82C.E5111910
Content-Type: text/html;
charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3DISO-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: STILL NEED HELP WITH JULIAN DATES</TITLE>
</HEAD>
<BODY>
<BR>
<P><FONT SIZE=3D2>You can try this function.</FONT>
<BR><FONT SIZE=3D2> </FONT>
</P>
<P><FONT SIZE=3D2>DEFINE =
jul_day =
CHAR(3)  =
; # Julian Date</FONT>
<BR><FONT SIZE=3D2>define =
juliand CHAR(3)</FONT>
</P>
<P><FONT SIZE=3D2> LET =
jul_day =3D tojulian(today) #Format DDD</FONT>
<BR><FONT SIZE=3D2> call =
tojulian(today) returning juliand</FONT>
</P>
<P><FONT SIZE=3D2>function tojulian(in_date) </FONT>
<BR><FONT SIZE=3D2>define</FONT>
<BR><FONT SIZE=3D2> in_date date,</FONT>
<BR><FONT SIZE=3D2> jul_val char(4),</FONT>
<BR><FONT SIZE=3D2> date_c char(10),</FONT>
<BR><FONT SIZE=3D2> date_d date,</FONT>
<BR><FONT SIZE=3D2> number_days integer,</FONT>
<BR><FONT SIZE=3D2> jul_days char(3)</FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2> if in_date is null</FONT>
<BR><FONT SIZE=3D2> then</FONT>
<BR><FONT SIZE=3D2> =
initialize jul_val to null</FONT>
<BR><FONT SIZE=3D2> else</FONT>
<BR><FONT SIZE=3D2> # calc =
last day of last year in char format</FONT>
<BR><FONT SIZE=3D2> let =
date_c[1,6] =3D "12/31/"</FONT>
<BR><FONT SIZE=3D2> let =
date_c[7,10] =3D year(in_date) - 1</FONT>
<BR><FONT SIZE=3D2> # convert to date =
format </FONT>
<BR><FONT SIZE=3D2> let =
date_d =3D date(date_c)</FONT>
</P>
<P><FONT SIZE=3D2> # number =
of days in current year</FONT>
<BR><FONT SIZE=3D2> let =
nnumber_days =3D in_date - date_d</FONT>
<BR><FONT SIZE=3D2> let =
jul_days =3D number_days using "&&&"</FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2> end if</FONT>
</P>
<P><FONT SIZE=3D2> return jul_val</FONT>
<BR><FONT SIZE=3D2>end function</FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2> </FONT>
</P>
<BR>
<BR>
<BR>
<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: thedude [<A =
HREF=3D"mailto:pdh...@directrans.com">mailto:pdh...@directrans.com</A>=
]</FONT>
<BR><FONT SIZE=3D2>Sent: Wednesday, January 08, 2003 5:44 PM</FONT>
<BR><FONT SIZE=3D2>To: inform...@iiug.org</FONT>
<BR><FONT SIZE=3D2>Subject: STILL NEED HELP WITH JULIAN DATES</FONT>
</P>
<BR>
<P><FONT SIZE=3D2>Hello,</FONT>
</P>
<P><FONT SIZE=3D2>Further to my HELP WITH JULIAN DATES posting, I know =
how to do the</FONT>
<BR><FONT SIZE=3D2>DATETIME() substraction to get a Julian date using =
ISQL, but the trouble I'm</FONT>
<BR><FONT SIZE=3D2>having is how do you do it within a 4GL program =
(i.e. using variables to</FONT>
<BR><FONT SIZE=3D2>hold the dates). Any help would be greatly =
appreciated. Thanx.</FONT>
</P>
<BR>
<BR>
</BODY>
</HTML>
------_=_NextPart_001_01C2B82C.E5111910--
What's the problem with:
DEFINE d1 DATE
DEFINE jd INTEGER
LET jd = d1 - MDY(1,1,YEAR(d1) + 1
--
Jonathan Leffler #include <disclaimer.h>
Email: jlef...@earthlink.net, jlef...@us.ibm.com
Guardian of DBD::Informix 1.04.PC1 -- http://dbi.perl.org/
The succinct answer to my own question is "missing close parentheses",
of course.
LET jd = d1 - MDY(1, 1, YEAR(d1)) + 1
Where's Captain Pedantic?
His wife probably beat him senseless and he is, no doubt, still in recovery.
With scissors?