Get date format for active page?

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

paues
Posts: 211
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Get date format for active page?

Postby paues » Tue May 12, 2026 11:45 pm

Is it possible to get the date format of the current page? So that I know that @dateval gives me the correct value.

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

Re: Get date format for active page?

Postby EViews Gareth » Thu May 14, 2026 3:34 pm

format or frequency? @pagefreq give the frequency.

Format is machine based, not page/file based.

paues
Posts: 211
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Re: Get date format for active page?

Postby paues » Thu May 14, 2026 10:53 pm

I was thinking date format. On a typical quarterly page, I'd like to get back "YYYY[Q]Q". I have often found code like this

Code: Select all

%old_date_format = @word( _ "YYYY YYYY YYYY YYYY YYYY YYYY YYYY YYYY YYYY YYYY YYYY " _ + "YYYY[S]S YYYY[Q]Q YYYY[M]MM " _ + "DD/MM/YYYY DD/MM/YYYY DD/MM/YYYY DD/MM/YYYY DD/MM/YYYY DD/MM/YYYY", _ @wfindnc( _ "20Y 10Y 9Y 8Y 7Y 6Y 5Y 4Y 3Y 2Y A " _ + "S Q M " _ + "BM F T W D7 D5", _ @pagefreq _ ) _ ) %new_date_format = "YYYY[M]MM" %date_in_new_format = @datestr(@dateval(%date_in_old_format, %old_date_format), %new_date_format)
which feels unstable and could be avoided if EViews supplied something like @pagedateformat to use instead of the unwieldy (and incomplete) expression for %old_date_format.

paues
Posts: 211
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Re: Get date format for active page?

Postby paues » Thu May 14, 2026 10:55 pm

By "machine based", do you mean that it depends on the locale of the machine?

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

Re: Get date format for active page?

Postby EViews Gareth » Sat May 16, 2026 5:44 am

No, it is a global setting in EViews.



I think there's probably an easy way to do what you want, but I don't understand, yet, what you're trying to do.

paues
Posts: 211
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Re: Get date format for active page?

Postby paues » Sat May 16, 2026 8:17 am

I want to be able to take a date string specified in the format of current page and then unambiguously convert that string to a date value.

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

Re: Get date format for active page?

Postby EViews Gareth » Sat May 16, 2026 3:02 pm

@dateval usually just figures it out without needing a format

paues
Posts: 211
Joined: Fri Apr 15, 2011 7:16 am
Location: Stockholm, Sweden

Re: Get date format for active page?

Postby paues » Sat May 16, 2026 10:05 pm

Indeed. But then once in a while, it doesn’t. And then it’s harder to build something dependable on it.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 3 guests