<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META content="MSHTML 6.00.2900.3157" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV><SPAN class=077195701-21092007><FONT face=Arial color=#0000ff size=2>Thanks
Murray..</FONT></SPAN></DIV>
<DIV><SPAN class=077195701-21092007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=077195701-21092007><FONT face=Arial color=#0000ff size=2>That
is infinetely better than anything I've seen!
:-0</FONT></SPAN></DIV>
<DIV><SPAN class=077195701-21092007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=077195701-21092007><FONT face=Arial color=#0000ff size=2>No...
that's great really... thank you. I never thought of using
matchpattern().</FONT></SPAN></DIV>
<DIV><SPAN class=077195701-21092007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=077195701-21092007><FONT face=Arial color=#0000ff
size=2>cheers</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=077195701-21092007><FONT face=Arial color=#0000ff size=2>ps..
say hi to Rod for me.</FONT></SPAN></DIV>
<DIV> </DIV><!-- Converted from text/rtf format -->
<P><SPAN lang=en-us><FONT face=Arial color=#0000ff size=2>Kind
regards,</FONT></SPAN> </P>
<P><SPAN lang=en-us><FONT face="Courier New" size=2>---</FONT></SPAN>
<BR><B><SPAN lang=en-au><FONT face=Arial size=2>Fernando Olmos</FONT></SPAN></B>
<BR><SPAN lang=en-au><FONT face=Arial color=#808080 size=2>Senior Analyst
Programmer</FONT></SPAN><SPAN lang=en-us></SPAN> <BR><SPAN lang=en-us><B><FONT
face=Arial size=2>HPA</FONT></B></SPAN> <BR><SPAN lang=en-us><FONT face=Arial
color=#808080 size=2>Direct:</FONT><B> <FONT face=Arial color=#808080 size=2>03
9217 5411</FONT></B></SPAN> <BR><SPAN lang=en-us><FONT face=Arial color=#808080
size=2>Fax: 03 9217 5166</FONT></SPAN> <BR><SPAN lang=en-us></SPAN><A
href="http://www.hpa.com.au/"><SPAN lang=en-us><U></U><U><B></B></U><U><B><FONT
face=Arial color=#000000 size=2>www.hpa.com.au</FONT></B></U></SPAN></A><SPAN
lang=en-us></SPAN> </P>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B>
murray.scholz@abri.une.edu.au [mailto:murray.scholz@abri.une.edu.au]
<BR><B>Sent:</B> Friday, 21 September 2007 11:49 AM<BR><B>To:</B> Fernando
Olmos<BR><B>Cc:</B> powerh-l@lists.sowder.com<BR><B>Subject:</B> Re: A proper
date conversion function?<BR><BR></FONT></DIV>Hi Fernando,<BR><BR>I agree , a
dateconv() function would make life a load easier.<BR><BR>We frequently deal
with incoming data using the something similar to following...<BR><BR>Once you
'uncover' new possibilities that are coming in, it's just a matter of adding a
new 'style' to the 1st define, and then picking off the components that are
required. Tedious & somewhat pedestrian I know, but it's easy code
to follow...<BR>You could include fancy checks for leap years
etc.<BR><BR>define fld-2 char*50 = "24102001"<BR><BR>define fld-2-style int*4
= 1 if matchpattern(fld-2,"##(/|-)##(/|-)#### *")
&<BR> else 2 if
matchpattern(fld-2,"##(/|-)#(/|-)#### *")
&<BR> else 3 if
matchpattern(fld-2,"#(/|-)##(/|-)#### *")
&<BR> else 4 if
matchpattern(fld-2,"#(/|-)#(/|-)#### *")
&<BR> else 9 if
matchpattern(fld-2,"######## *")
&<BR> else 0<BR>define fld-2-dd
int*9 = 0 if fld-2-style = 0
&<BR> else nconvert(fld-2[1:1])
if fld-2-style = 3 or fld-2-style = 4
&<BR> else
nconvert(fld-2[1:2])<BR>define fld-2-mm int*9 = 0 if fld-2-style = 0
&<BR> else nconvert(fld-2[4:2])
if fld-2-style = 1 &<BR> else
nconvert(fld-2[4:1]) if fld-2-style = 2
&<BR> else nconvert(fld-2[3:2])
if fld-2-style = 3 or fld-2-style = 9
&<BR> else
nconvert(fld-2[3:1])<BR>define fld-2-yyyy int*9 = 0 if fld-2-style = 0
&<BR> else nconvert(fld-2[7:4])
if fld-2-style = 1 &<BR> else
nconvert(fld-2[6:4]) if fld-2-style = 2 or fld-2-style = 3
&<BR> else
nconvert(fld-2[5:4])<BR>define fld-2-n int*9 = 0 if fld-2 = " "
&<BR> else 0 if fld-2-dd = 0 or
fld-2-mm = 0 or fld-2-yyyy = 0
&<BR> else 0 if fld-2-mm > 12
or fld-2-dd > 31 &<BR> else 0
if fld-2-dd > 30 and (fld-2-mm = 2 or fld-2-mm = 4 or fld-2-mm = 6 or
fld-2-mm = 9 or fld-2-mm = 11)
&<BR> else 0 if fld-2-dd > 28
and fld-2-mm = 2 &<BR> else
(10000 * fld-2-yyyy) + (100 * fld-2-mm) + fld-2-dd<BR><BR>define fld-2-date
date = fld-2-n<BR><BR>Regards<BR>Murray Scholz<BR><PRE class=moz-signature cols="72">Agricultural Business Research Institute
University of New England
Armidale NSW 2351 Australia
Email <A class=moz-txt-link-abbreviated href="mailto:murray.scholz@abri.une.edu.au">murray.scholz@abri.une.edu.au</A>
</PRE><BR><BR><BR><A class=moz-txt-link-abbreviated
href="mailto:fernando.olmos@hpa.com.au">fernando.olmos@hpa.com.au</A> wrote:
<BLOCKQUOTE cite=midC5B2133CD2641C4EA593D2143A5FA0A8A7D128@exchange2k
type="cite">
<META content="MS Exchange Server version 6.0.6619.12" name=Generator><!-- Converted from text/rtf format -->
<P><FONT face=Arial size=2>Hi everyone.</FONT> <BR><FONT face=Arial
size=2>This is interesting… there must be a good date conversion function,
using defines, out there that is better than mine…</FONT> </P>
<P><FONT face=Arial size=2>This only works with dd/mm/yyyy, where dd and mm
can be either single or two values. What if the field t_field_03 (char*50 by
the way) has an invalid date like "1212/344/54874" or a valid date of
ddmmyyyy?</FONT></P>
<P><FONT face=Arial size=2>From the client that sends us the files, they can
send us anything, including any valid date like ddmmyyyy, dd-mm-yyyy, dmy,
dmmyyyy, ddmyyyy, dmyyyy, etc… so we have to cater for all possible dates.
It's a shame COGNOS didn't think of writing a dateconv() function that
actually converts any date to a valid date data type. If there is one,
please let me know as I am pulling out my hair with all these defines!
hehehe</FONT></P>
<P><FONT face="Courier New" size=2>;Get the date required, but making sure
that day and month</FONT> <BR><FONT face="Courier New" size=2>;is properly
adjusted if they are single digits. Format of the</FONT> <BR><FONT
face="Courier New" size=2>;date has to come in with 'slash' characters in
the format: dd/mm/yyyy</FONT> </P>
<P><FONT face="Courier New" size=2>define t_slash1 num*2 =
index(t_field_03,"/")</FONT> <BR><FONT face="Courier New" size=2>define
t_mmyyyy char*7 = t_field_03[(t_slash1 + 1):7]</FONT> <BR><FONT
face="Courier New" size=2>define t_slash2 num*2 = index(t_mmyyyy,"/")</FONT>
<BR><FONT face="Courier New" size=2>define t_date_required_d char*2 =
t_field_03[1:(t_slash1 - 1)] &</FONT> <BR><FONT face="Courier New"
size=2> if t_slash1 > 2 and
t_rec_type = 1 &</FONT> <BR><FONT face="Courier New"
size=2> else "0" + t_field_03[1:(t_slash1 - 1)]
&</FONT> <BR><FONT face="Courier New"
size=2> if t_rec_type = 1</FONT>
<BR><FONT face="Courier New" size=2>define t_date_required_m char*2 =
t_mmyyyy[1:(t_slash2 - 1)] &</FONT> <BR><FONT face="Courier New"
size=2> if t_slash2 > 2 and
t_rec_type = 1 &</FONT> <BR><FONT face="Courier New"
size=2> else "0" + t_mmyyyy[1:(t_slash2 - 1)]
&</FONT> <BR><FONT face="Courier New"
size=2> if t_rec_type = 1</FONT>
<BR><FONT face="Courier New" size=2>define t_date_required_y char*4 =
t_mmyyyy[(index(t_mmyyyy,"/") + 1):4] &</FONT> <BR><FONT
face="Courier New" size=2> if t_rec_type
= 1</FONT> <BR><FONT face="Courier New" size=2>define t_date_required_c
char*8 = pack(trunc(t_date_required_y) + &</FONT> <BR><FONT
face="Courier New"
size=2>
trunc(t_date_required_m) + &</FONT> <BR><FONT face="Courier New"
size=2>
trunc(t_date_required_d)) &</FONT> <BR><FONT face="Courier New"
size=2>
if t_num_error <> "C" &</FONT>
<BR><FONT face="Courier New"
size=2>
and t_rec_type = 1 &</FONT>
<BR><FONT face="Courier New"
size=2>
else "0"</FONT> <BR><FONT face="Courier New" size=2>define t_date_required
date = nconvert(t_date_required_c)</FONT> </P><BR><BR></BLOCKQUOTE><PRE class=moz-signature cols="72"></PRE></BLOCKQUOTE><pre>**********************************************************************
IMPORTANT
The contents of this e-mail and its attachments are confidential and intended
solely for the use of the individual or entity to whom they are addressed. If
you received this e-mail in error, please notify the HPA Postmaster, postmaster@hpa.com.au,
then delete the e-mail.
This footnote also confirms that this e-mail message has been swept for the
presence of computer viruses by Ironport. Before opening or using any
attachments, check them for viruses and defects.
Our liability is limited to resupplying any affected attachments.
HPA collects personal information to provide and market our services. For more
information about use, disclosure and access see our Privacy Policy at
www.hpa.com.au
**********************************************************************
</pre></BODY></HTML>