number of workdays

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

Cscottmcwall-ea
Posts: 8
Joined: Mon Mar 11, 2024 6:09 am

number of workdays

Postby Cscottmcwall-ea » Wed Apr 17, 2024 6:27 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13327
Joined: Tue Sep 16, 2008 5:38 pm

Re: number of workdays

Postby EViews Gareth » Wed Apr 17, 2024 7:32 am

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
Follow us on Twitter @IHSEViews

Cscottmcwall-ea
Posts: 8
Joined: Mon Mar 11, 2024 6:09 am

Re: number of workdays

Postby Cscottmcwall-ea » Wed Apr 17, 2024 9:41 am

Thanks that makes sense is it easy to get the first and last workday as a date from the temp monthly page?

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13327
Joined: Tue Sep 16, 2008 5:38 pm

Re: number of workdays

Postby EViews Gareth » Wed Apr 17, 2024 10:09 am

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.
Follow us on Twitter @IHSEViews

Cscottmcwall-ea
Posts: 8
Joined: Mon Mar 11, 2024 6:09 am

Re: number of workdays

Postby Cscottmcwall-ea » Thu Apr 18, 2024 2:25 am

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

EViews Matt
EViews Developer
Posts: 564
Joined: Thu Apr 25, 2013 7:48 pm

Re: number of workdays

Postby EViews Matt » Thu Apr 18, 2024 12:48 pm

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)

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13327
Joined: Tue Sep 16, 2008 5:38 pm

Re: number of workdays

Postby EViews Gareth » Thu Apr 18, 2024 2:29 pm

Show off.
Follow us on Twitter @IHSEViews


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 5 guests