I've been handed a project that has involved me in having to write some jave script.
I am a complete and utter novice with no previous coding experience.
I basically need to collect a prevous days file every morning. The file is kept in a directory on the remote server which is named with this convention 'YYYYMMDD' I'm currently using this syntax for the variable for the remote directory:
// format remote directory name
var REMOTEDIR =
pad(date.getFullYear(), 4) +
pad(date.getMonth()+1, 2) +
However I have now realised there are issues with this code when it gets to the first day of the month.
Could anyone please provide with an idiots guide on how to set this variable in the event of it being the first day of the month and having to roll back a month and set the number of days to the correct last day of the month.
I presume it uses a combination of get dates and if/else's.
Even a template of the code if anyone has had to do this before.
Any help would be more than appreciated