String dates: the last day of x-quarters ahead

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

tvonbrasch
Posts: 459
Joined: Fri Apr 15, 2011 5:35 am

String dates: the last day of x-quarters ahead

Postby tvonbrasch » Sun Mar 17, 2019 12:29 am

Hi

How can i get the string date for the last day of x-quarters ahead, i.e. when

x=1: I want the string: "30/06/2019" (the last day of the second quarter, i.e x= 1 quarter ahead)
x=2: I want the string: "30/09/2019" (the last day of the third quarter, i.e. x= 2 quarters ahead)

etc...

Thomas

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

Re: String dates: the last day of x-quarters ahead

Postby EViews Matt » Sun Mar 17, 2019 11:03 am

Hello,

I believe that would be: @datestr(@dateceil(@dateadd(@date, x, "Q"), "Q"))

tvonbrasch
Posts: 459
Joined: Fri Apr 15, 2011 5:35 am

Re: String dates: the last day of x-quarters ahead

Postby tvonbrasch » Mon Mar 18, 2019 9:07 am

great, thanks!
Thomas

tvonbrasch
Posts: 459
Joined: Fri Apr 15, 2011 5:35 am

Re: String dates: the last day of x-quarters ahead

Postby tvonbrasch » Sat May 29, 2021 9:55 am

Hi,

why does the string _a return a question mark?
datestring.JPG
datestring.JPG (49.76 KiB) Viewed 1190 times


t

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

Re: String dates: the last day of x-quarters ahead

Postby EViews Gareth » Sun May 30, 2021 9:00 am

A quarter is 3 months.

Subtracting a quarter from 29th May (which is when I assume you did the operation, given that's when you posted the question), yields a result of 29th February. 29th February doesn't exist. So the result is an NA.
Follow us on Twitter @IHSEViews

tvonbrasch
Posts: 459
Joined: Fri Apr 15, 2011 5:35 am

Re: String dates: the last day of x-quarters ahead

Postby tvonbrasch » Sun May 30, 2021 12:05 pm

Great, thanks,

I would like to get a string with a date in the form "YYYY:Q", !X-quarters ago, using a code that works every day of the year.

Would this code do it?

Code: Select all

@datestr(@dateadd(@datefloor(@now,"q") , -!X, "Q"), "yyyy:q")


Do you have a better alternative?
t

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

Re: String dates: the last day of x-quarters ahead

Postby EViews Gareth » Sun May 30, 2021 9:35 pm

That's how I would do it (although in my mind I floored to start of the month rather than start of the quarter, but same effect).
Follow us on Twitter @IHSEViews

tvonbrasch
Posts: 459
Joined: Fri Apr 15, 2011 5:35 am

Re: String dates: the last day of x-quarters ahead

Postby tvonbrasch » Sun May 30, 2021 9:45 pm

Great, thanks. your feedback is, as always, highly appreciated!
t


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 8 guests