Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Month Start !

Team,

I am facing scenario as my script should run on:

  • Month start day ( eg 1st Aug)
  • Month start date should be week day (eg 'Mon''Tue''Wed''Thu''Fri') , if month 1 st day is 'Sat' or 'Sun' script should not run.
  • if month 1st day 'Sun' (Eg: 1 Aug) then script should run on next day (Eg : 2nd Aug Mon)

Will This Work:?


if match(Month Start(weekday(today()), 'Sun', 'Sat') )then

exit script;

end if

Script.


Please provide your Suggestion


Thanks in Advance!

7 Replies
arvind_patil
Partner - Specialist III
Partner - Specialist III

Hi Ashok,

May be like below:

If( MonthStart(today())= today() and not Wildmatch(weekday(today()), 'Sun', 'Sat')


ExPression 1;

IF(Monthstart (Today()+1= Today() and wildmatch(weekday(today()-1),'Sun','Sat')

ExPression 1;


))

Thanks,

Arvind Patil

Anonymous
Not applicable
Author

Arvind thanks for your suggestion, Can u please elaborate this code!!

tresesco
MVP
MVP

Try like:

If NOT today()=LastWorkDate(MonthStart(Today()),1) Then

     Exit Script;

End If

<Script>

Edit: correction (highlighted) in function.

Anonymous
Not applicable
Author

Tresesco thanks for your suggestion, Can u please elaborate this code!!

tresesco
MVP
MVP

It is supposed to do what you wished it to do.

LastWorkDate with argument 1 - moves the date ahead if it falls in weekend. That way, you can handle the situation when a month start date falls in weekend and get the next working date, i.e a Monday like you wanted. Then we are comparing, if it is NOT today then we can safely exit the script. Or, you can remove the NOT and include the script under the conditioning, telling, the script would be executed only when today() is a month start excluding weekend.

wilsonwebb
Partner - Contributor III
Partner - Contributor III

Hi Ashok,

My best advice to you would be to get a master calendar.

Anonymous
Not applicable
Author

Thanks for your explanation Tresesco!!