Focal Point
Convert 03-MAR-2007 to DMYY format

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/3031062712

March 09, 2007, 07:32 AM
StuBouyer
Convert 03-MAR-2007 to DMYY format
Greetings,

I have seen ways to convert a date from DMYY format to DD-MMM-YYYY (where MMM is the Month name abbreviation) but can't work out how to go back the other way.

For example I want to change 03-MAR-2007 to be 03032007.

Thanks in adavance

Stuart


WebFOCUS 8.2.03 (8.2.06 in testing)
March 09, 2007, 09:25 AM
Tom Flynn
quote:
03-MAR-2007


DATE1/A3 = EDIT(IN_DATE,'$$$999');
DATE2/A2 = DECODE DATE1(
'JAN' '01'
'FEB' '02'
'MAR' '03'
'APR' '04'
'MAY' '05'
'JUN' '06'
'JUL' '07'
'AUG' '08'
'SEP' '09'
'OCT' '10'
'NOV' '11'
'DEC' '12');
DATE3/A8 = EDIT(DATE_IN,'99') | DATE2 | EDIT(DATE_IN,'$$$$$$$9999');
DATE4/I8 = EDIT(DATE3);

Tom


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
March 09, 2007, 10:28 AM
Alan B
Or:
  
-SET &TDATE='18-MAR-2007';
-SET &UDATE = EDIT(&TDATE,'99$ 999$ 9999');
DEFINE FILE Fn
NDATE/D|M|YY = '&UDATE';
-* OPTIONALLY
MDATE/A8DMYY=NDATE;
PDATE/A8=MDATE;
END



Alan.
WF 7.705/8.007
March 09, 2007, 10:38 AM
FrankDutch
Guru's

IMHO this depends also of the format the date is stored in the database
It might be a smartdate that only is presented as SDATE/DDtrMYYYY.
And the solutions depend on the language.
In my language is the 5th month 'MEI'.

Last remark:
he was asking for
quote:
to convert a date from DMYY format to DD-MMM-YYYY

The example was the other way around.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

March 09, 2007, 11:36 AM
Alan B
Frank

The question was:
quote:

For example I want to change 03-MAR-2007 to be 03032007.

not as you quoted in your reply, in fact he said
quote:

I have seen ways to convert a date from DMYY format to DD-MMM-YYYY

Tom and I each gave an answer based solely on the question that was asked, not on a generic international date conversion routines.

These answers only give a flavour of what can be achieved, and how. In that respect our answers are good until the questioner says differently.


Alan.
WF 7.705/8.007
March 11, 2007, 05:37 AM
StuBouyer
Alan and Tom,

Thanks for your help. you have moved me closer to do what I need to. Unfortunately, I realized after reading your responses that I forgot a major part of the question.

I need to compare the date (which is extracted from a alphanumeric string) with a date taken from a datetime stamp in oracle.

I extract the date from the datetime using
DMYY_DATE/DMYY = HDATE(IN_DATETIME, DMY_DATE);

But if I compare DMYY=DATE with Tom's DATE4 it always fails the compare (even when they are the same). I'm doing the compare in a define
MATCHED/A3 = IF DATE4 EQ DMYY_DATE THEN 'YES' ELSE 'NO';
but it always returns NO

What I need (or at least what I think I need) is to get the string '03032007' to be a smart date, but DATECVT complains about wrong format of argument 1 and CHGDAT returns nothing (an empty string I presume).

Thanks

Stuart


WebFOCUS 8.2.03 (8.2.06 in testing)
March 11, 2007, 06:56 AM
Tom Flynn
quote:
DATE1/A3 = EDIT(IN_DATE,'$$$999');
DATE2/A2 = DECODE DATE1(
'JAN' '01'
'FEB' '02'
'MAR' '03'
'APR' '04'
'MAY' '05'
'JUN' '06'
'JUL' '07'
'AUG' '08'
'SEP' '09'
'OCT' '10'
'NOV' '11'
'DEC' '12');
DATE3/A8 = EDIT(DATE_IN,'99') | DATE2 | EDIT(DATE_IN,'$$$$$$$9999');
DATE4/I8 = EDIT(DATE3);


Stuart,

For mine, CHG:

DATE4/I8 = EDIT(DATE3);
to
DATE4/I8DMYY = EDIT(DATE3);

Then ADD:

DATE5/DMYY = DATE4;

For Alan's, which is much more efficient code, ADD:

XDATE/I8DMYY = EDIT(MDATE);
YDATE/DMYY = XDATE;


quote:
MATCHED/A3 = IF DATE4 EQ DMYY_DATE THEN 'YES' ELSE 'NO';


MATCHED/A3 = IF DATE5 or YDATE from Alan EQ DMYY_DATE THEN 'YES' ELSE 'NO';

Tom

This message has been edited. Last edited by: Tom Flynn,


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
March 11, 2007, 08:08 AM
FrankDutch
take a look here

https://forums.informationbuilders.com/eve/forums/a/tpc/...951026891#6951026891

or you should buy the book...




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

March 11, 2007, 03:16 PM
Tom Flynn
Hey Stuart,

Obviously, you are new to the site, and, possibly WebFOCUS? 2 whole posts and you get a cantankerous individual who obviously LOVES WebFOCUS!!!

Most of us on the site enjoy the professional mentoring side, especially when utilizing a new tool; others just can't get away from their anal retentive side. Some are still waiting for the Moon over Parador to rise, or, their Lotto numbers to come in...

Don't take it personally,; there are some great mentors here and, the site itself, is a plethora of information.

There are many ways to climb the WebFOCUS mountain, so, Keep the questions coming...

Tom

Edit: Spellcheck!!!

This message has been edited. Last edited by: Tom Flynn,


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
March 11, 2007, 08:46 PM
StuBouyer
Tom,

Many thanks, yes you are correct I'm new to both the forums and webfocus. I'm still having teething problems with the multitude of date formats and converting between them.

I've been lurking a few weeks on the forums and agree with you that most people on the site are more than helpful. I'm fairly thick skinned and won't let a few RTFM posts stop me from posting.

Many thanks for you help Tom and Alan. This forums is an excellent resource for the newbie webfocus user.

And Frank, when I get the FM I will RTFM, once it arrives, but AusPost ain't the fastest when it comes to shipping from the US.

Stuart


WebFOCUS 8.2.03 (8.2.06 in testing)
March 12, 2007, 04:07 AM
FrankDutch
Stuart

My remark on the books was not meant as a push to RTFM, but more as a suggestion on a good piece of info.

This FP site is also for me a great help and sometimes better than any book.

Frank




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7