Retrieving date format?

For questions regarding programming in the EViews programming language.

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

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

Retrieving date format?

Postby paues » Wed Jan 30, 2013 1:02 am

Is there some way to retrieve the format from a date? I have noticed that the @date() in the pagestruct command senses the date format of its argument series. Is this functionality available also outside pagestruct? If not, is there some way to retrieve the date format that is used in a page's sample/range?

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

Re: Retrieving date format?

Postby EViews Gareth » Wed Jan 30, 2013 9:17 am

I'm not sure I understand what you're asking - a page doesn't have a "date format".

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

Re: Retrieving date format?

Postby paues » Wed Jan 30, 2013 2:33 pm

A page's sample/range is specified by two dates. Those dates have format. Is there someway to retrieve that format? Or, for that matter, the format for any arbitrary date string?

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

Re: Retrieving date format?

Postby EViews Gareth » Wed Jan 30, 2013 3:13 pm

That format is not stored with the workfile. It is a global setting in that particular copy of EViews. There is no way to retrieve a user's particular setting.

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

Re: Retrieving date format?

Postby paues » Wed Jan 30, 2013 3:27 pm

Alright. But is there any way to retrieve the format of an arbitrary date? So, that I from "2010Q3" could get "YYYY[Q]Q"?

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

Re: Retrieving date format?

Postby EViews Gareth » Wed Jan 30, 2013 4:08 pm

I'm going to interpret that to mean that you have a string or some sort (a string object, a % variable or an alpha series) that contains a string representation of a date, and you want to retrieve the format of that string representation. There is no function to do that.

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

Re: Retrieving date format?

Postby paues » Wed Jan 30, 2013 11:28 pm

That was precisely what I meant :-) Would you consider adding it? It seems that the functionality is already there as the code below yields the expected result.

Code: Select all

!mydateval=@dateval("2012Q3")
Ideally, there would be a @dateformat function that takes a date string, e.g. "2012Q3", and an optional date value (corresponding to the string) and returns the date format of the string. Just as @dateval it would not always succeed. Then it would return "NA".

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

Re: Retrieving date format?

Postby EViews Gareth » Wed Jan 30, 2013 11:49 pm

The problem is that it is often ambiguous without the date value, and sometimes ambiguous even with the date value.

What is @dateformat("2012:1"), even if given a date value corresponding to Jan 1st 2012?

How about "01/01/2012"?

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

Re: Retrieving date format?

Postby EViews Gareth » Wed Jan 30, 2013 11:53 pm

Or, I give you the date value for 12 December 2012, and ask for the date format of "12/12/12". What is that format?

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

Re: Retrieving date format?

Postby paues » Thu Jan 31, 2013 1:09 am

"NA" I guess :-) To me that seems exactly the type of example that would leave also @dateval puzzled. I am not at my computer right now but I presume that @dateval("10/11/12") would similarly return NA.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests