Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Powershell work with files created with previous Date after midnight..

Status
Not open for further replies.

PaulSc

MIS
Aug 21, 2000
148
GB
Hello
I'm after a bit of help please in regards to the best way to handle a issue i have with a small "app" Ive inherited...

this is a small PowerShell GUI/code which controls a handover document for a 3 shift rota system (i.e days, eves, nights). Each day we create 3 text files into a dated subfolder which are then edited throughout each shift via the "app" and then reviewed/updated etc and archived the next morning where the cycle starts again.

my "problem" is with the night shift handover in that the file /folder is created for "today" (i.e. 20200619) at the start of each day when the day shift starts (07:00) which is fine but the night shift itself then starts at 23:00 and goes on until 07:00 the next day. When they start they open the current days file but once it hits midnight, it then tries to open the folder/file for the following date ie. the one dated 20200620 which doesnt exist.

Weve tried pre-allocating the day ahead but this then means that we may have part of the handover saved in the 20200619 file and part after midnight in the 20200620 file...weve tried checking/comparing the time
too and whilstt this made it a bit better when they keep the app active, if the apps restarted after midnight all the dates shifted again and we were back to square 1...

Current thinking is to now save the date into another external file when the logs are created and read this date each time to retrieve the right file but wonder if anyone can suggest a possible alternate soltution please.

Apologies but I'm unable to publish any of the code due to "security" restrictions in place (and understand that this may restrict any help or responses I receive but all will be appreciated...)

Regards
PaulSc
 
your best option would be to change your application to work based on start of shift period - would require some kind of configuration and logic but would work.
e.g.
shift 1 - from 7 to 15 - folder name = current date + 1 (shift 1) (20200619_1)
shift 2 - from 15 to 23 - folder name = current date + 2 (shift 2) (20200619_2)

shift 3 would require logic - if current time is < 7 use previous day else use current day
shift 3 - from 23 to 07 (+1) - folder name = date from logic + 3 (shift 3) (20200619_3)

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top