peterrb
(Peterrb)
December 21, 2023, 5:48pm
1
Hello,
I am trying to add 31 days to a DateTime variable (MinStartDate) but the calendar year and month are not updating correctly. i.e. the MinStartDate is 04/03/2024 and I keep getting 04/04/2024.
Dateadd(“d”,31,MinStartDate).ToString(“dd/MM/yyyy”)
Thank you!
vrdabberu
(Varunraj Dabberu)
December 21, 2023, 5:53pm
2
Hi @peterrb
Assign: MinStartDate = "04/03/2024"
Assign: StartDate = DateTime.ParseExact(MinStartDate , "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Assign: NewDate = MinStartDate.AddDays(31)
Log Message: NewDate.ToString("dd/MM/yyyy")
Specify the output what you need so that I will change the syntax accordingly.
Regards
peterrb
(Peterrb)
December 21, 2023, 6:24pm
3
I need the output to read 05/04/2024, basically 31 calendar days after the MinStartDate with month and year updating based on a calendar.
vrdabberu
(Varunraj Dabberu)
December 21, 2023, 6:27pm
4
Hi @peterrb
Try this:
Assign: MinStartDate = "04/03/2024"
Assign: StartDate = DateTime.ParseExact(MinStartDate , "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
Assign: NewDate = MinStartDate.AddDays(31)
Log Message: NewDate.ToString("MM/dd/yyyy")
Regards,
peterrb
(Peterrb)
December 21, 2023, 7:01pm
6
My assign activity for StartDate is giving me the following error. My MinStartDate variable is a DateTime.
Hello,
Check that the type of your StartDate variable is of type system.datetime
What is the type of MinStartDate?
So you don’t need to do ParseExact, just assign StartDate = MinStartDate.addDays(31)
peterrb
(Peterrb)
December 21, 2023, 7:21pm
12
Thank you for all of your help!
1 Like
system
(system)
Closed
December 24, 2023, 7:21pm
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.