Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
My code in load script
reportdate:
load max([Bill Date]) as max_data
resident GroupOther;
LET vReportDate = date(num(AddMonths('max_data',-1,'reportdate')),'MM-DD-YYYY');
Will this code work, if i need for Previous month "12-05-2023"? please help.
Thanks.
No, this code will not work. max_data is not available as a field just so. You have to get it first from your table and then transform and format it:
LET vReportDate = peek('max_data', 0, 'reportdate');
LET vReportDate = Date(AddMonths($(vReportDate), -1), 'DD-MM-YYYY');
Okay, so if i call this variable in my another code(below), which vReportDate it will take here or we can just changed it like that?
LET vReportDate = peek('max_data', 0, 'reportdate');
LET vReportDate1 = Date(AddMonths($(vReportDate), -1), 'DD-MM-YYYY');
LET vReportFilename = 'GroupSummary ' & '$(vReportDate1)' & '.xls';
//Export to excel is done with Post Reload trigger
You can change your code as suggested.
However the second variable definition, LET vReportDate = Date(AddMonths($(vReportDate), -1), 'DD-MM-YYYY');, overwrites the first, i.e. the value of vReportDate will be the result of this expression. If you don't need the original date as a variable, you don't need to define vReportDate1.