Page 1 of 1
number of workdays
Posted: Wed Apr 17, 2024 6:27 am
by Cscottmcwall-ea
Hey I have a 5 day week frequency workfile and need to create a series that returns the number of workdays in a month at the moment im using @datediff(@dateceil(@date,"m"),@datefloor(@date,"m"),"b") but this wont work if the first or last day of the month is a weekend
Thanks
Re: number of workdays
Posted: Wed Apr 17, 2024 7:32 am
by EViews Gareth
I'd do it just by creating a temporary monthly page.
Code: Select all
wfcreate(page=daily) d5 2000 2024
pagecreate(page=monthly) m 2000 2024
series days = @daycount("Mon-Fri")
copy monthly\days daily\days
pageselect daily
Re: number of workdays
Posted: Wed Apr 17, 2024 9:41 am
by Cscottmcwall-ea
Thanks that makes sense is it easy to get the first and last workday as a date from the temp monthly page?
Re: number of workdays
Posted: Wed Apr 17, 2024 10:09 am
by EViews Gareth
Create a series equal to @date on the daily page. Copy it over to the monthly page using "first" as the frequency conversion. Then copy it again using "last" as the frequency conversion. That will give you a series of the dates of the first workday and last weekday of each month.
Re: number of workdays
Posted: Thu Apr 18, 2024 2:25 am
by Cscottmcwall-ea
Thanks it would be great if there was a command that could do this or add in an option in dateceil and datefloor for workdays
Re: number of workdays
Posted: Thu Apr 18, 2024 12:48 pm
by EViews Matt
Hello,
I'll contribute the following snippet. So long as the very first and last months are fully included within the D5 workfile range, the following expression will generate the number of business days in the current month:
Code: Select all
@maxsby(@periodtodate(1, @month), @month, @year)
Re: number of workdays
Posted: Thu Apr 18, 2024 2:29 pm
by EViews Gareth
Show off.