Page 1 of 1

date conversion

Posted: Wed Dec 18, 2013 6:41 am
by antipa
hello,

I would like to transform a series containing dates in numerical form (year*10000+month*100+day) into a date string. Also, is it possible to use this date string to then structure my workfile?

thanks a lot in advance

Re: date conversion

Posted: Wed Dec 18, 2013 11:40 am
by EViews Glenn
From the docs
The @makedate function is used to translate ordinary numbers into date numbers. It is similar to @dateval but is designed for cases in which your dates are encoded in one or more numeric values instead of date strings:
...
@makedate(arg1[, arg2[,arg3]], fmt): takes the numeric values given by the arguments arg1, and optionally, arg2, etc. and returns a date number using the required format string, fmt.
...
Among the built-in formats is
“yymmdd” or “yyyymmdd”: year*10000 + month*100 + day in month.
So, if the coded dates are in the series A, then

Code: Select all

series date = @makedate(a, "yyyymmdd")
will create a date series that you can use to structure the workfile. You can use the @datestr function to create a string representation of the numbers in the date series, as in

Code: Select all

alpha datest = @datestr(date, "yyyy/mm/dd")
where you substitute whatever valid format you would like in the last argument.