Page 1 of 1

String dates: the last day of x-quarters ahead

Posted: Sun Mar 17, 2019 12:29 am
by tvonbrasch
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

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

Posted: Sun Mar 17, 2019 11:03 am
by EViews Matt
Hello,

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

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

Posted: Mon Mar 18, 2019 9:07 am
by tvonbrasch
great, thanks!
Thomas

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

Posted: Sat May 29, 2021 9:55 am
by tvonbrasch
Hi,

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

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

Posted: Sun May 30, 2021 9:00 am
by EViews Gareth
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.

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

Posted: Sun May 30, 2021 12:05 pm
by tvonbrasch
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

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

Posted: Sun May 30, 2021 9:35 pm
by EViews Gareth
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).

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

Posted: Sun May 30, 2021 9:45 pm
by tvonbrasch
Great, thanks. your feedback is, as always, highly appreciated!
t