I need to do a while to AddDays to the Initial Date like this :
The $Start or $Stop Variable need to be a string when the command line with the split are execute !
(Format Date is: dd/mm/YYYY HH:MM)As you see after the AddDays (Format is: mm/dd/YYYY HH:MM)
and each time the AddDays is execute the format is switch !
I have try with [Datetime] just before the AdfdDays but seem’s to be same error !
Could you please explain a little more detailed what you are trying to do (not the attempted solution you think you need). And if you get errors you shoud post them as well please (formatted as code as well please).
It’s again for my NetBackup Script, i need to Fill the command line for set a Incremental Schedule of a backup Policy.
The command line is :
StartTimeJ and StopTimeJ are an array.
The -0 is Sunday
-1 Monday
etc…
and each couple of StartTimeJ and StopTimeJ is :
StartTimeJ : the Hour in second since Midnight
StopTimeJ is a duration in second.
This two value is get with New-TimeSpan.
So What i want to do is to calculate the value of each StartTime end StopTime !
For this i need :
The Date and hour of begining
The date and hour of the duration
The date of Ending backup
after i’m using the command line Get date to now the day of begining
Use New-TimeSpan to have the time in second and difference between startTime and stopTime to have the value in second of StopTime
I need to have the numebr of days between the start and Ending to create the while.
The error i see :
The format (%d/%m/%Y %H:%M) change to (%m/%d/%Y %H:%M) and the AddDays don’t works normally, the result i wait is :
Sorry, I still did not get what you actually trying to calculate. Could you please provide a complete example command line like you would expect it? So not with the variables like this:
Going back to the script .\bpplscedwin, I would update it to accept the backup schedule as an array of Hash Tables, one Hash Table for each of the 7 days of the week as in:
Sam, the problem i see with your way, is we must fill the Hour of StartTime and StopTime each days.
I need this will be calculate by the script not by the user ending.
But what for would you need the actual date. bpplschedwin takes only the day of the week anyway. There’s no representation for the 9th of April 2020 - it’s Thursday. So it’s “-4”.
So a complete work week with the start at 16:00 and the end at 06:00 the next day would be this:
Value of i : 0
StartTime - before AddDays:
StartTime - After AddDays: 03/00/2020 16:00
Value of i : 1
StartTime - before AddDays: 03/00/2020 16:00
StartTime - After AddDays: 04/00/2020 16:00
Value of i : 2
StartTime - before AddDays: 04/00/2020 16:00
StartTime - After AddDays: 05/00/2020 16:00
Value of i : 3
StartTime - before AddDays: 05/00/2020 16:00
StartTime - After AddDays: 06/00/2020 16:00
Value of i : 4
StartTime - before AddDays: 06/00/2020 16:00
StartTime - After AddDays: 07/00/2020 16:00
Value of i : 5
StartTime - before AddDays: 07/00/2020 16:00
StartTime - After AddDays: 08/00/2020 16:00
Ok…Now i’m Crazy !
The Add is pretty good ! but…the month change to 00 ??
Tell me the bug is in my head.
I need to actual date because, for example when we have a maintenance the week End and we could not done a full backup, we want to make possible to do an Incremental during this maintenance Week-End.