## 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

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

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

great, thanks!
Thomas

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

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

Hi,

why does the string _a return a question mark?
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

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.

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

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

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

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).

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

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

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

### Who is online

Users browsing this forum: No registered users and 8 guests