Good morning!
Is there a way to combine the @datefloor, @datepart, @weekday, and @datestr (or some combination of functions) to return a string that is the first Friday of the current year?
I'm thinking something like:
%mydate=@datestr(@datepart(@datefloor(@date),"dd"),"mm/dd/yyyy"), except I'm not sure how to point the code to the first friday.
Thanks!
Bob
Code to determine date of first Friday of the year
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Code to determine date of first Friday of the year
Hello,
I believe this will work:
I believe this will work:
Code: Select all
%mydate = @datestr(@datefloor(@date, "y") + 6 - @mod(@datepart(@datefloor(@date, "y"), "w") + 1, 7), "mm/dd/yyyy")
Re: Code to determine date of first Friday of the year
Hi Matt!
Thanks for your reply! I receive a "non-numeric argument" error when trying that code. I tried adding a @datestr() to the second half, but it didn't resolve the error. Any thoughts?
Thanks for your reply! I receive a "non-numeric argument" error when trying that code. I tried adding a @datestr() to the second half, but it didn't resolve the error. Any thoughts?
Re: Code to determine date of first Friday of the year
Got it figured out!
%mydate=@datestr(6 - @mod(@datepart(@datefloor(@dateval(@date), "y"), "w") + 1, 7),"mm/dd/yyyy")
Thanks!
%mydate=@datestr(6 - @mod(@datepart(@datefloor(@dateval(@date), "y"), "w") + 1, 7),"mm/dd/yyyy")
Thanks!
Re: Code to determine date of first Friday of the year
i actually didn't figure it out. but i think i'm close. that returns "1/7/1"
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Code to determine date of first Friday of the year
My apologies, I pasted a genr expression for the calculation instead of a scalar context expression. Just replace to two @date references with @now...
Code: Select all
%mydate = @datestr(@datefloor(@now, "y") + 6 - @mod(@datepart(@datefloor(@now, "y"), "w") + 1, 7), "mm/dd/yyyy")
Who is online
Users browsing this forum: No registered users and 30 guests