Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Previous Business day

I have a variable vPrevBussday=date(today()-1), how do I work in Saturday and Sunday. If it is Monday or Sunday ot should still go back to Friday as PrevBusssday

Tags (1)
1 Solution

Accepted Solutions

Re: Previous Business day

May be this:

=If(WeekDay(Today()) = 'Mon', Date(Today() - 3),

If(WeekDay(Today()) = 'Sun', Date(Today() - 2), Date(Today() - 1)))

7 Replies

Re: Previous Business day

May be this:

=If(WeekDay(Today()) = 'Mon', Date(Today() - 3),

If(WeekDay(Today()) = 'Sun', Date(Today() - 2), Date(Today() - 1)))

Re: Previous Business day

Hi,

another solution could be something like:

Date(Today()+3-RangeMax(4,WeekDay(Today()-1)))

QlikCommunity_Thread_199117_Pic1.JPG

QlikCommunity_Thread_199117_Pic2.JPG

hope this helps

regards

Marco

MVP
MVP

Re: Previous Business day

Hi,

Simply use FirstWorkDate() for this

=If(WeekDay(Today()) = 'Sun' OR WeekDay(Today()) = 'Sat', firstworkdate (Today(), 1), firstworkdate (Today(), 2) )

From Qlikview Help file:

firstworkdate(end_date, no_of_workdays {, holiday} )

Returns the latest starting date to achieve number_of_workdays (Monday-Friday) ending no later than end_date taking into account any optionally listed holidays. End_date and holiday should be valid dates or timestamps.

Examples:

firstworkdate ('2007-03-01', 9) returns '2007-02-19' 

firstworkdate ('2006-12-31', 8, '2006-12-25', '2006-12-26') returns '2006-12-18' 

Re: Previous Business day

that surely seems to be easier.

thanks

regards

Marco

Siva_Sankar
Honored Contributor

Re: Previous Business day

Not applicable

Re: Previous Business day

Thank you all,I tried 2 of these solutions and achieved what I needed

Re: Previous Business day

Please close your thread if your question is answered.

Thanks

Regards

Marco

Community Browser