Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ECHO OFF
- SET FirstDate=2015-01-24
- REM These indexes assume %DATE% is in format:
- REM Abr MM/DD/YYYY - ex. Sun 01/25/2015
- SET TodayYear=%DATE:~10,4%
- SET TodayMonth=%DATE:~4,2%
- SET TodayDay=%DATE:~7,2%
- REM Construct today's date to be in the same format as the FirstDate.
- REM Since the format is a comparable string, it will evaluate date orders.
- IF %TodayYear%-%TodayMonth%-%TodayDay% GTR %FirstDate% (
- ECHO Today is after the first date.
- ) ELSE (
- ECHO Today is on or before the first date.
- )
- and / or
- @ECHO OFF
- SETLOCAL ENABLEEXTENSIONS
- REM -- 2 digit day
- SET "_day=%DATE:~-10,2%" & REM day goes first (dd/mm/yyyy); if not, remove this line
- SET "_day=%DATE:~-7,2%" & REM day goes second (mm/dd/yyyy); if not, remove this line
- REM -- 2 digit month
- SET "_month=%DATE:~-10,2%" & REM month goes first (mm/dd/yyyy); if not, remove this line
- SET "_month=%DATE:~-7,2%" & REM month goes second (dd/mm/yyyy); if not, remove this line
- REM -- 4 digit year
- SET "_year=%DATE:~-10,4%" & REM year goes first (yyyy/##/##); if not, remove this line
- SET "_year=%DATE:~-4%" & REM year goes last (##/##/yyyy); if not, remove this line
- REM -- The variables below are set to year-month-day without separators (yyyymmdd)
- SET "today=%_year%%_month%%_day%" & REM today's date based on your selections above
- SET "compareDate=20180727" & REM the date you are comparing with today
- REM -- Here's where the magic happens with comparing the two dates
- IF %compareDate% LSS %today% ECHO The comparison date is in the past.
- IF %compareDate% EQU %today% ECHO The comparison date is today.
- IF %compareDate% GTR %today% ECHO The comparison date is in the future.
- GOTO :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement