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
String dates: the last day of x-quarters ahead
Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator
-
- Posts: 540
- Joined: Fri Apr 15, 2011 5:35 am
-
- EViews Developer
- Posts: 562
- 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"))
I believe that would be: @datestr(@dateceil(@dateadd(@date, x, "Q"), "Q"))
-
- Posts: 540
- Joined: Fri Apr 15, 2011 5:35 am
Re: String dates: the last day of x-quarters ahead
great, thanks!
Thomas
Thomas
-
- Posts: 540
- 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?
t
why does the string _a return a question mark?
t
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- 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.
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
-
- Posts: 540
- 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?
Do you have a better alternative?
t
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
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- 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).
Follow us on Twitter @IHSEViews
-
- Posts: 540
- 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
t
Who is online
Users browsing this forum: No registered users and 19 guests