Focal Point
Date format in heading not printing properly
May 18, 2006, 02:40 PM
GuilloDate format in heading not printing properly
I am trying to print the date used as a report input parameter to the report title but to display it in a different format. I am current prompting for START_DT whose date format is YYMD (ie: 20060930). When I add this to the heading title for display as &START_DT, it displays fine as 20060930. I want to display is as 09/30/2006.
I have added a define to change the format of the prompt field:
df_START_DT/MDYY = &START_DT
The code for the heading is as follows:
HEADING
"Billing Account Report"
"PO Nbr : &PO_NBR , Vendor :
"Date Range From : &Start_DT
When I run it a get the error: INVALID DATE CONSTANT.
I've tried other formats but get similiar results. What am I doing wrong?
May 18, 2006, 02:52 PM
susannahGuillo, you've got to convert it first.
It starts life as a characterstring.
you have to convert it from a character string to a smart date.
You can use the DATECVT function if you like, it works fine in DM.
There are a lot of other ways
| In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID |
May 18, 2006, 03:33 PM
GuilloSusannah, thank you for the quick response.
I've tried the following format on the DEFINE:
df_Start_DT/MDYY = DATECVT(&Start_DT,YYMD,MDYY);
But after running it I get:
(FOC258) FIELDNAME OR COMPUTATIONAL ELEMENT NOT RECOGNIZED: YYMD
Is the input format for the DATECVT function the right one?
May 18, 2006, 03:50 PM
Francis MarianiSyntax:
DATECVT(date, 'infmt', 'outfmt');
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
May 18, 2006, 03:54 PM
GuilloI believe that I've used the format as you've indicated. I guess what I'm asking is, is the standard form for dates actually YYMD since what is displayed and entered in the prompt is in the form of: 20061001 (YYMD)?
May 18, 2006, 05:49 PM
Sandy Weller-SET &START_DT ='20060906';
DEFINE FILE CAR
DF_START_DX/YYMD = DATECVT(&START_DT,'I8YYMD','YYMD');
DF_START_DT/MDYY = DATECVT('&START_DT','A8YYMD','MDYY');
END
TABLE FILE CAR
PRINT DF_START_DT
DF_START_DX
BY COUNTRY
END
The quotes around the in and out are required and since &start_dt is not really YYMD you need I8 or A8 and quotes as needed.
Sandy
May 18, 2006, 05:53 PM
susannahnuance...format YYMD indicates a 'smart date'
a smart date is an integer , the number days elapsed since the beginning of the last millenium, its a number on the order of 38000.
Your &var date is most likely 20060517
which isn't YYMD, its I8YYMD, even tho it might
look like YYMD, it isn't.
| In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID |
May 19, 2006, 07:55 AM
codermonkeyDM "thinks" in alpha or numeric only. You can define a smart date field directly from a DM variable. I think yours didn't work because you tried to drop &START_DT into a MDYY and 20 is not a valid month.
Although you've been given a solution, I wanted to post about why your initial approach didn't work. You could have tweaked it as follows:
-SET &VAR1 = 20060930;
DEFINE FILE CAR
DATE1/YYMD = &VAR1;
DATE2/MDYY = DATE1;
-* or if you want to do it in one step...
DATE3/MDYY =
EDIT(EDIT('&VAR1','$$$$99') | EDIT('&VAR1','$$$$$$99') | EDIT('&VAR1','9999'));
END
-*
TABLE FILE CAR
HEADING
"DATE2:
"DATE3: PRINT COUNTRY
END
Always a bunch of ways to do stuff in FOCUS....
May 19, 2006, 09:28 AM
<Aparna>quote:
Originally posted by Guillo:
I am trying to print the date used as a report input parameter to the report title but to display it in a different format. I am current prompting for START_DT whose date format is YYMD (ie: 20060930). When I add this to the heading title for display as &START_DT, it displays fine as 20060930. I want to display is as 09/30/2006.
I have added a define to change the format of the prompt field:
df_START_DT/MDYY = &START_DT
The code for the heading is as follows:
HEADING
"Billing Account Report"
"PO Nbr : &PO_NBR , Vendor : "Date Range From : &Start_DT
When I run it a get the error: INVALID DATE CONSTANT.
I've tried other formats but get similiar results. What am I doing wrong?
is &START_DT an input field then you need to user it as
df_START_DT/MDYY = '&START_DT';
one minor change. put &START_DT in single quotes
May 22, 2006, 07:24 AM
GuilloThank you all for your responses.
I applied the approach that Sandy suggested and it worked beautifully. I only had to add the DEFINE statements as follows:
df_Start_DT/MDYY = DATECVT('&Start_DT','A8YYMD','MDYY');
df_End_DT/MDYY = DATECVT('&End_DT','A8YYMD','MDYY');
The final results printed, which is what I was after, was:
Date Range From : 10/01/2005 To : 09/29/2006
This approach seemed simple to apply with good results.