How can I get the following done:
I am running a focexec 5 days aweek which is monday thru friday that produces huge data file each run. the data file is named with the date it runs on.
I need to add into my fex to find the data file from yesterday run and change it to a different extension, then delete the older data files. to do that, first I have this DOWK function finding the day of the week. If monday, goes back 3 days to get to friday otherwise, go back previous day. This works fine if we are in the middle of the month without any problem. But when first day of the month is monday (or any other day) for example, then how do I have the fex to set up to go back the previous month and find the last friday of that previous month?
any easier way to do this? any help is appreciated!
Use business day as in the following examples from ibi:
Example: Setting Business Days
Business days are traditionally Monday through Friday, but not every business has this schedule. You can determine which days are considered business days and which days are not. For example, if your company does business on Sunday, Tuesday, Wednesday, Friday and Saturday, you can tailor business day units to reflect that schedule.
Then when you use DATEADD, DATEDIF, or DATEMOV, these functions ignore dates that are not business days.
Syntax: How to Set Business Days
SET BUSDAYS = smtwtfs
Is the seven-character list of days that represents your business week. The list has a position for each day from Sunday to Saturday.
If you want a day of the week to be a business day, enter the first letter of that day in that day's position.
If you want a day of the week not to be a business day, enter an underscore (_) in that day's position.
If a letter is not in its correct position, or if you replace a letter with a character other than an underscore, you receive an error message.
To expand on what Vipul said, here is another solution:
DEFINE FILE CAR
TODAY_YYMD/YYMD = 'AUG 02 2004';
TODAY_W/W = TODAY_YYMD;
OFFSET/I03 = DECODE TODAY_W (1 3 2 1 3 1 4 1 5 1);
LAST_RUN/YYMD = DATEADD(TODAY_YYMD,'D',-OFFSET);
TABLE FILE CAR
PRINT TODAY_YYMD LAST_RUN
WHERE RECORDLIMIT IS 1
Kmafu, you're probably going to want to do this in dialog manager;
here's how i do it:
to begin, remember that &YYMD is a sytem variable
(in win2k), so whatever plaform you're on, use whatever is the approp. system variable for today.
-SET &DAY = DOWK(&YYMD,'A3');
-SET &ADJ = DECODE &DAY('MON' 3 'TUE' 1 'WED' 1 'THU' 1 'FRI' 1 'SAT' 1 'SUN' 2);
-SET &ADJ = -1 * &ADJ ;
-SET &MYDATE = AYMD(&YYMD, &ADJ, 'I8YYMD');
-SET &MYDATE1 = EDIT(&MYDATE,'$$999999');
-SET &MYFILE = 'FN' | &MYDATE1 | '.FOC';
-SET &OUTFILE = 'FN' | &MYDATE1 | '.OLD';
CMD COPY &MYFILE &OUTFILE
-* so what ive done is use the DOWK function to figure out the Day of Week, and the AYMD function to add a number (in this case a negative number) to a date and keep it in smartdate form. (Adding -1 to August 1st gets you July 31st.) Then i make a string that is my filename using the adjusted date.
Then i copy (or rename) the file, remember to put the approp. directory syntax in.
Susannah,excellent help! exactly what I am looking for! thanks a ton!
THANKS everybody for all the help and suggestions!
thanks very much!
|Powered by Social Strata|