Weeknumber minus 1

Discuss RoboTask here
Post Reply
rice1973
Posts: 86
Joined: Mon Jan 04, 2010 2:38 am
Location: Netherlands
Contact:

Weeknumber minus 1

Post by rice1973 »

Hello Oleg,

What do i have to change to set the week number minus 1 by the variable ; {WeekOfTheYear({Date})}
And at what day does the new week start? Is it on monday?

Kind regards,

Maurice
Robotask rules! :)
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Weeknumber minus 1

Post by Oleg »

New week begins on Monday.

See the example below how to calculate WeekOfTheYear-1

Code: Select all

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task730"
Hide=INTEGER|0
ID=INTEGER|73766993
LogOnAsUser=INTEGER|1
Name=STRING|"Week of the year - 1"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""WEEKNUM"" with value ""{WeekOfTheYear({Date})}"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"1"
varkind=STRING|"1"
varname=STRING|"WEEKNUM"
varvalue=STRING|"{WeekOfTheYear({Date})}"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""WeekNum"""
Params=FOLDER

[Actions\Action2\Params]
incement=STRING|"-1"
vaiable=STRING|"WeekNum"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""[{Time}, {DayOfWeek}, {Date}]"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"[{Time}, {DayOfWeek}, {Date}]"
msg1=STRING|"Week of the Year: {WeekOfTheYear({Date})}"
msg2=STRING|"Week of the Year - 1: {WeekNum} "
msgcount=STRING|"3"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
rice1973
Posts: 86
Joined: Mon Jan 04, 2010 2:38 am
Location: Netherlands
Contact:

Re: Weeknumber minus 1

Post by rice1973 »

Ok,

Is it not as simple as {IncDays(-1)} ?
Robotask rules! :)
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Weeknumber minus 1

Post by Oleg »

What do you want to get: yesterday's date or number of previous week?
{IncDays(-1)} - the day number (not week number or date)
{DateIncDays(-1)} - the date of yesterday
Oleg Yershov
rice1973
Posts: 86
Joined: Mon Jan 04, 2010 2:38 am
Location: Netherlands
Contact:

Re: Weeknumber minus 1

Post by rice1973 »

I want to get the number of previous week. :)
Robotask rules! :)
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Weeknumber minus 1

Post by Oleg »

So, look at my example above.
Oleg Yershov
Micha
Posts: 7
Joined: Fri Feb 15, 2019 9:50 am

Re: Weeknumber minus 1

Post by Micha »

Where to use the code when I want to use the variable? Should I copy the code to "Local variables"???
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Weeknumber minus 1

Post by Oleg »

Where to use the code when I want to use the variable? Should I copy the code to "Local variables"???
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
You can see the task and use task editor to edit it and see all parameters of each step
Oleg Yershov
Post Reply