Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

LastWorkDate and FirstWorkDate including Saturdays

Hello!

I'm not able to find a the LastWorkDate and FirstWorkDate functions excluding only Sundays (and not Saturdays).

Is there something like that?

If not, I've tried to write the function:

Function FirstWorkDay(StartDate, Direction, NofDays)

   

    FinalDate = StartDate

   

    Counter = 0

   

    Do While Counter<= NofDays

       

        If Direction= "P" Then

            FinalDate= DateAdd("d", -1, FinalDate)

        Else

            FinalDate= DateAdd("d", 1, FinalDate)

        End If

   

        If Weekday(FinalDate) <> 7 Then

           Counter= Counter+ 1

        End If

   

    Loop

   

    FirstWorkDay= FinalDate

End Function

What's wrong?

Thank you.

N.

1 Reply
Anil_Babu_Samineni

What are you going to achieve here?

Just assume, if your script like below from that which values you are going to get

Load weekday, date where weekday <> 'Sun';

Load weekday(date) as weekday, date;

Load date(mindate + iterno() - 1) as date

While date(mindate+iterno()-1) <= maxdate;

Load makedate(2017)as mindate,

Now() as maxdate

Autogenerate 1;

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful