Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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

1 Solution

Accepted Solutions
sunny_talwar

May be this:

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

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

View solution in original post

7 Replies
sunny_talwar

May be this:

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

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

MarcoWedel

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

jagan
Luminary Alumni
Luminary Alumni

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' 

MarcoWedel

that surely seems to be easier.

thanks

regards

Marco

Siva_Sankar
Master II
Master II

Not applicable
Author

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

MarcoWedel

Please close your thread if your question is answered.

Thanks

Regards

Marco