Last day of previous month
Last day of previous month
Is there a variable combination that can have Robotask populate the last date of a previous month? So for example when running a report in the end date for the date field I need to populate 06/30/2020 as that was the final day of the previous month.
Re: Last day of previous month
I'm somewhat new to Robotask... But I'll bet you could get today's date as format "dd" then subtract "dd+1" from the current date. For example today is July 14th, so that would be "14." Add one is 15. So then use the Global Variable called {DateIncDays(-7)} which appears to be "current date +/- number of days. Today minus 15 should be June 30.tcarvalho wrote:Is there a variable combination that can have Robotask populate the last date of a previous month? So for example when running a report in the end date for the date field I need to populate 06/30/2020 as that was the final day of the previous month.
Maybe?
EDIT: Actually, As I look at a calendar... Maybe you wouldn't need to add +1. Today (14th) minus 14 would be one day before July 1st. Hence June 30th.
Re: Last day of previous month
Yes, of course.Maybe you wouldn't need to add +1. Today (14th) minus 14 would be one day before July 1st. Hence June 30th.
Use the expression {DateIncDays(-{Day})}
Also look at the small example
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1604865554
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task222"
Hide=INTEGER|0
ID=INTEGER|1946255170
LogOnAsUser=INTEGER|1
Name=STRING|"last date of previous month"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
[Actions\Action1]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""last date of previous month"""
Params=FOLDER
[Actions\Action1\Params]
icon=STRING|"1"
msg0=STRING|"last date of previous month"
msg1=STRING|"{DateIncDays(-{day})}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
Re: Last day of previous month
Wow -- only one step needed in the task. Pretty cool. 

Re: Last day of previous month
Thank you Oleg, but I forgot one of the reports is actually 2 months behind, but again needs to be the last day of that month. Is that also possible with this expression?Oleg wrote: Use the expression {DateIncDays(-{Day})}
Re: Last day of previous month
The only way I can imagine this working (for month before last), is to use a loop.
Start with a date that is "today minus 60 days." Then increment it forward one day at a time. With each loop save the currently evaluated date (formatted as "dd") to a variable, and the day after the currently evaluated day as another variable. When "Var_day_after" is less than "var_currently_evaluated" then break from the loop--you are at the end of the month.
Start with a date that is "today minus 60 days." Then increment it forward one day at a time. With each loop save the currently evaluated date (formatted as "dd") to a variable, and the day after the currently evaluated day as another variable. When "Var_day_after" is less than "var_currently_evaluated" then break from the loop--you are at the end of the month.