×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

working with dates

working with dates

working with dates

(OP)
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

RE: working with dates

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.

RE: working with dates

(OP)
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

RE: working with dates

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

RE: working with dates

(OP)
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

RE: working with dates

(OP)
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

RE: working with dates

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

RE: working with dates

(OP)
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
-P

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close