Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

working with dates

Status
Not open for further replies.

pvuppa1

Programmer
Nov 14, 2003
61
US
Can anyone tell me how to play with dates. I need to be able to manipulate the user input frm YY format to YYMMDD to be date and month specific reports. In a nutshell, user will provide me an year and I need to be able to generate reports based on that year
Eg., for the year 1900, I need to creat a report for 4 quarters in a year like for 19000101(jan) 19000401(apr) 19000801(aug) 19001201(dec)
Please help.
Thank
-P
 
Sure, you can define a field like;

TESTDT/A8YYMD='UserYear' | '0401';

where UserYear is, for example, 2003. TESTDT will then display in a report as;

2003/04/01

You can also compute a real date as;

REALDT/YYMD=TESTDT;

if you need a date field for date arithmetic, sorting, etc.
 
Thanks Kiddpete,
It really helped me but I need to add +1 for the year field inorder to process for 3rd and 4th qtrs. The fiscal yr starts from July01
Qtr1Start/A8YYMD='useryear' | 0701;
Qtr1End/A8YYMD='useryear' | 0931;
Qtr2Start/A8YYMD='useryear' | 1001;
Qtr2End/A8YYMD='useryear' | 1231;

how do i add useryear+1
i tried
compute
useryr/yy='useryear'+1;
useryear1/A8YYMD= useryr;
gave me an error message..
Please help
 
If useryear is a numeric field, you could compute:

workyear/I4=useryear+1;

then:

TESTDT/A8YYMD=EDIT(workyear) | '0401';

If useryear is a alphanumeric field, then:

workyear/I4=EDIT(useryear)+1;

and, if useryear is an amper (&) variable, you could;

-SET &useryear=&useryear+1;

then compute:

TESTDT/A8YYMD='&useryear' | '0401';


HTH
 
Hi Kiddpete,
sorry to post the same question in two threads but I still cant find what I was looking for, please bear with me for just a moment
here's what i have with me
1.
DEFINE FILE MYFILE
YEAR/YY='&REPORT_YYYY';

TESTDT1/A8YYMD='YEAR' | '0701';
BEGDATE/YYMD=TESTDT1;TESTDT2/A8YYMD='YEAR' | '0931';
ENDDATE/YYMD=TESTDT2;

TESTDT3/A8YYMD='YEAR' | '1001';
BEGDATE1/YYMD=TESTDT3;
TESTDT4/A8YYMD='YEAR' | '1231';
ENDDATE1/YYMD=TESTDT4;


*****After this point I need Year=Year+1...I tried all the methods like you said. Please Help

TESTDT5/A8YYMD='YEAR'| '0101';
BEGDATE2/YYMD=TESTDT5;
TESTDT6/A8YYMD='YEAR'| '0331';
ENDDATE2/YYMD=TESTDT6;

TESTDT7/A8YYMD='YEAR'| '0401';
BEGDATE3/YYMD=TESTDT7;
TESTDT8/A8YYMD='YEAR'| '0630';
ENDDATE3/YYMD=TESTDT8;

( for some reason when i display BEGDATE it gives me ********)
2.
For displaying quarters accross I have
BEGMONTH/M=BEGDATE;
BEGMONTH1/M=BEGDATE1;
BEGMONTH2/M=BEGDATE2;
BEGMONTH3/M=BEGDATE3;
QUARTER/I1=IF BEGMONTH FROM 7 TO 9 THEN 1 ELSE
IF BEGMONTH1 FROM 10 TO 12 THEN 2 ELSE
IF BEGMONTH2 FROM 1 TO 3 THEN 3 ELSE
IF BEGMONTH3 FROM 4 TO 6 THEN 4;
QRTNUM/A3=DECODE QUARTER(1, '1ST', 2, '2ND', 3, '3RD', 4, '4TH');
but it just displays only "2nd" even when I have begmonth1/2/3 falling in different months..
PLEASE HELP
 
I think my question is how to change the date format from year in I4 to YYMD with my own MD.
DEFINE MYFILE
YEAR/I4='&USER_YEAR';
TESTDT/A8YYMD=EDIT('YEAR') | '0701';
REALDT/YYMD=TESTDT;
END
Something is wrong with the format
-P
 
OK, assuming that &USER_YEAR is 2003, your YEAR compute should be:

YEAR/I4=&USER_YEAR;

since YEAR is a numeric field. Further, one function of EDIT is converting integers to alphanumeric, so you write that compute as;

TESTDT/A8YYMD=EDIT(YEAR) | '0701';

Notice that, in both cases, your quotes have been removed. However, you don't need YEAR in this case. You can use &USER_YEAR directly as;

TESTDT/A8YYMD='&USER_YEAR' | '0701';

You need the quotes in this case because you are building an alphanumeric string. The DEFINE FILE will actually 'see' the following;

TESTDT/A8YYMD='2003' | '0701';

which is two alphanumeric strings being concatenated. Now, when you want to set up a value for next year, your code would be;

-SET &USER_YEAR=&USER_YEAR+1;
NEXTDT/A8YYMD='&USER_YEAR' | '0701';

It looks contradictory doesn't it? Its not. Dialogue Manager does not have a real strong data typing function, so the same amper variable can be used as a number on one line while being used as alpha numeric on the next line.

HTH
 
Thank you so much and I appreciate ur help.
That was the first step i had to clear to do something more complicated.
I hope you can help me in my future postings.
Thanks for ur time
[neutral]-P

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top