FULLSCREEN CONTENTS Project Home Page
.EXAMPLE.....: 44 Do something on the last day (or last Friday) of the month
.ALIAS.......: 44
.CATEGORY....: examples 
.CODE........:

COMMENT
We often need batch files that do some special task on the last day of the
month: run a backup job, display a reminder message, etc.  This example
batch file, LASTDAY.BAT, simply displays a message -- you can modify it to
do whatever it is that YOU want to do.

If you plan to run LASTDAY.BAT at work, and you work Monday through Friday,
then checking for the last day of the month would be a poor strategy --
after you leave work on a Friday, the last day of the month might occur on
the following Saturday or Sunday.   So I've included a check to see if the
Friday is the last working day of the month.  If you don't want that
functionality, deleting the lines between the first and last occurrence of
the string "EndCheck" will remove it.
=======================================================================
 @echo off
 :: ---------------------------------------------------------------
 :: check to see if today is the last day of the month
 :: ---------------------------------------------------------------
 :: get today's month
 fdate /ff        /omm /vmmtoday

 :: get tomorrow's month
 fdate /fadd /n1 /omm  /vmmtomorrow

 :: if tomorrow occurs in a different month,
 :: then today is the last day of this month
 if not (%mmtoday%)==(%mmtomorrow%) echo LAST DAY OF THE MONTH
 if not (%mmtoday%)==(%mmtomorrow%) goto EndCheck

 :: -------------------------------------------------------------
 :: check to see if today is the last Friday of the month
 :: -------------------------------------------------------------
 :: get today's day of the week, to see if it is Friday
 fdate /ff /odow3 /vdow3
 if not (%dow3%)==(Fri) goto EndCheck

 :: today is Friday.   Get next Monday's month
 fdate /fadd /n3 /omm  /vmmMonday

 :: if next Monday occurs in a different month,
 :: then today is the last Friday of this month
 if not (%mmtoday%)==(%mmMonday%) echo LAST WORKING DAY OF THE MONTH

 :EndCheck

 :: cleanup
 set dow3=
 set mmtoday=
 set mmtomorrow=
 set mmMonday=