Skip to main content
Announcements
WEBINAR April 23, 2025: Iceberg Ahead: The Future of Open Lakehouses - REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
ivandrago
Creator II

MakeDate 6 Months Ago

Hi,

I want to make a change to the MakeDate(2015,03) so that it always 6 months previous of todays date but not sure how to do this, as at the moment I am having to hard code the values and was looking at variable to replace the Year and Month?

FOR i = 1 to 6

LET vDate$(i) = Date(AddMonths(MakeDate(2015,03),i-1),'DD-MMM-YYYY'); 

Thanks

5 Replies
JonnyPoole
Former Employee

let v6MonthsAgo= Date(Addmonths(Today(),-6));

...This would give you a date 6 months back from today's date.  If you do this in the load script, it would only be updated when the script runs.

If you use this, it will evaluate dynamically based on today's date whether the app was reloaded that date or not.

set v6MonthsAgo= Date(Addmonths(Today(),-6));


or you also can do it in the UI variables.

ivandrago
Creator II
Author

so with my current script I have what do I need to change?

JonnyPoole
Former Employee

Your current script creates 6 different variable from 1 to 6 months prior from a hardcoded month of 201503.

Based on your description you just need 1. You can use this to do that and instead of a hard coded date, make it dynamic to today's date

set v6MonthsAgo= Date(Addmonths(Today(),-6));

ivandrago
Creator II
Author

Sorry yes I still want it to do the multiple months as with my script it does a loop but I want it to always start 6 months ago, so basically I want it to loop through the following dates:

01-MAR-2015

01-APR-2015

01-MAY-2015

01-JUN-2015

01-JUL-2015

01-AUG-2015

Thanks

tresesco
MVP

Try this:

FOR i = 1 to 6

LET vDate$(i) = Date(MonthStart(Today(),-$(i)),'DD-MMM-YYYY');

Next