Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

STILL NEED HELP WITH JULIAN DATES

3 views
Skip to first unread message

thedude

unread,
Jan 8, 2003, 5:43:37 PM1/8/03
to
Hello,

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.


Wang, Mike PEO EIS TIS

unread,
Jan 9, 2003, 5:17:28 PM1/9/03
to

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_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>&nbsp;</FONT>
</P>

<P><FONT SIZE=3D2>DEFINE&nbsp; =
jul_day&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
CHAR(3)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp; # Julian Date</FONT>
<BR><FONT SIZE=3D2>define&nbsp; =
juliand&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CHAR(3)</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LET =
jul_day =3D tojulian(today) #Format DDD</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp; in_date date,</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; jul_val char(4),</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; date_c char(10),</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; date_d date,</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; number_days integer,</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; jul_days char(3)</FONT>
<BR><FONT SIZE=3D2>&nbsp;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; if in_date is null</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; then</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
initialize jul_val to null</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; else</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # calc =
last day of last year in char format</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let =
date_c[1,6] =3D &quot;12/31/&quot;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let =
date_c[7,10] =3D year(in_date) - 1</FONT>
<BR><FONT SIZE=3D2>&nbsp; # convert to date =
format&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let =
date_d =3D date(date_c)</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # number =
of days in current year</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let =
nnumber_days =3D in_date - date_d</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let =
jul_days =3D number_days using &quot;&amp;&amp;&amp;&quot;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; end if</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; return jul_val</FONT>
<BR><FONT SIZE=3D2>end function</FONT>
<BR><FONT SIZE=3D2>&nbsp;</FONT>
<BR><FONT SIZE=3D2>&nbsp;</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).&nbsp; Any help would be greatly =
appreciated.&nbsp; Thanx.</FONT>
</P>
<BR>
<BR>

</BODY>
</HTML>
------_=_NextPart_001_01C2B82C.E5111910--

Jonathan Leffler

unread,
Jan 10, 2003, 3:11:19 AM1/10/03
to


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/

Jonathan Leffler

unread,
Jan 11, 2003, 1:37:47 AM1/11/03
to
Jonathan Leffler wrote:
> thedude wrote:
>> [...] I know how to do [it, but] how do you do it within a 4GL
>> program?

>
> What's the problem with:
>
> DEFINE d1 DATE
> DEFINE jd INTEGER
> LET jd = d1 - MDY(1,1,YEAR(d1) + 1


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?

Impy

unread,
Jan 13, 2003, 10:14:35 AM1/13/03
to

"Jonathan Leffler" <jlef...@earthlink.net> wrote in message
news:3E1FBB78...@earthlink.net...
> Jonathan Leffler wrote:
>
> Where's Captain Pedantic?

His wife probably beat him senseless and he is, no doubt, still in recovery.


Andrew Hamm

unread,
Jan 13, 2003, 5:33:26 PM1/13/03
to
Impy wrote:
> "Jonathan Leffler" <jlef...@earthlink.net> wrote

>>
>> Where's Captain Pedantic?
>
> His wife probably beat him senseless and he is, no doubt, still in
> recovery.

With scissors?


0 new messages