Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have to calculate past 2 working days.
I have date field -createddate
07/30/2015
07/31/2015
07/25/2015
07/24/2015
How to calculate past 2 working days during the load.
I tried network days-doesn't work.
I can avoid Saturday and Sunday.
Are you looking to create a flag for last two working days???
Try the following script:
Table:
LOAD createddate,
If(WeekDay(Today()) = 'Sun', If(createddate = Today()-2 or createddate = Today()-3, 1, 0),
If(WeekDay(Today()) = 'Mon', If(createddate = Today()-3 or createddate = Today()-4, 1, 0),
If(WeekDay(Today()) = 'Tue', If(createddate = Today()-4 or createddate = Today()-1, 1, 0),
If(createddate = Today()-1 or createddate = Today()-2, 1, 0)))) as Flag;
LOAD Date(42004 + IterNo()) as createddate
AutoGenerate 1
While IterNo() <= 365;
Output:
Attaching the qvw for your reference as well.
HTH
Best,
Sunny
Try,
LOAD *,
NetWorkDays(createddate-2,createddate) as WorkDays;
LOAD Date(42004 + IterNo()) as createddate
AutoGenerate 1
While IterNo() <= 365;
Please see the attached
Table:
LOAD
createddate,
if(match(NetWorkDays(createddate, Today()),1,2), 1, 0) as Flag;
LOAD Date(makedate(2015) + IterNo()-1) as createddate
AutoGenerate 1 While IterNo() <= 365;