Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Last thursday date for CM from today() function

Hi experts.

I'm looking for some way to get calendar options from today() function,

Can QV get date for last thursday for current month using today()?

For example, in dimension i need to get 29.12.2016

Thanks.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

If you are specifically searching for the last thursday of a month, then maybe use something like

=DayName(Monthend(today())- Mod(Weekday(Monthend(today()))-3,7))

View solution in original post

13 Replies
Anonymous
Not applicable
Author

Anonymous
Not applicable
Author

Thanks.

Could you explain me please, how it works?

vishsaggi
Champion III
Champion III

From Reference Manual Help:

lastworkdate(start_date, no_of_workdays {, holiday})

Returns the earliest ending date to achieve number_of_workdays (Monday-Friday) if starting at start_date taking into account any optionally listed holidays. Start_date and holiday should be valid dates or timestamps.

Examples:

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

lastworkdate ('2006-12-18', 8, '2006-12-25', '2006-12-26') returns '2006-12-29' 

vishsaggi
Champion III
Champion III

Try this?

= FirstWorkDate(Monthend(Today()), 2)

swuehl
MVP
MVP

If you are specifically searching for the last thursday of a month, then maybe use something like

=DayName(Monthend(today())- Mod(Weekday(Monthend(today()))-3,7))

johnw
Champion III
Champion III

Only works for some months. For days in November, for instance, it will return 11/29/16, which is a Tuesday.

vishsaggi
Champion III
Champion III

Oops I missed that. Thanks John for that.

swuehl
MVP
MVP

Or if you want to flag dates in your master calendar, you can do it like

LOAD *,

if(Weekday(Date) =3 and Day(Date) >Day(Monthend(Date))-7,1,0) as Flag1,

  If(Date = Floor(Monthend(Date)- Mod(Weekday(Monthend(Date))-3,7)),1,0) as Flag2

;

LOAD *, Weekday(Date) as Weekday;

LOAD Date(Makedate(2016,1,1)+recno()-1) as Date

AutoGenerate 365;

Date Weekday Flag1 Flag2
28.01.2016Do11
25.02.2016Do11
31.03.2016Do11
28.04.2016Do11
26.05.2016Do11
30.06.2016Do11
28.07.2016Do11
25.08.2016Do11
29.09.2016Do11
27.10.2016Do11
24.11.2016Do11
29.12.2016Do11
Anonymous
Not applicable
Author

Dears, thanks for help!