Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. @ECHO OFF
  2.  
  3. SET FirstDate=2015-01-24
  4.  
  5. REM These indexes assume %DATE% is in format:
  6. REM Abr MM/DD/YYYY - ex. Sun 01/25/2015
  7. SET TodayYear=%DATE:~10,4%
  8. SET TodayMonth=%DATE:~4,2%
  9. SET TodayDay=%DATE:~7,2%
  10.  
  11. REM Construct today's date to be in the same format as the FirstDate.
  12. REM Since the format is a comparable string, it will evaluate date orders.
  13. IF %TodayYear%-%TodayMonth%-%TodayDay% GTR %FirstDate% (
  14. ECHO Today is after the first date.
  15. ) ELSE (
  16. ECHO Today is on or before the first date.
  17. )
  18.  
  19.  
  20. and / or
  21.  
  22. @ECHO OFF
  23. SETLOCAL ENABLEEXTENSIONS
  24.  
  25. REM -- 2 digit day
  26. SET "_day=%DATE:~-10,2%" & REM day goes first (dd/mm/yyyy); if not, remove this line
  27. SET "_day=%DATE:~-7,2%" & REM day goes second (mm/dd/yyyy); if not, remove this line
  28. REM -- 2 digit month
  29. SET "_month=%DATE:~-10,2%" & REM month goes first (mm/dd/yyyy); if not, remove this line
  30. SET "_month=%DATE:~-7,2%" & REM month goes second (dd/mm/yyyy); if not, remove this line
  31. REM -- 4 digit year
  32. SET "_year=%DATE:~-10,4%" & REM year goes first (yyyy/##/##); if not, remove this line
  33. SET "_year=%DATE:~-4%" & REM year goes last (##/##/yyyy); if not, remove this line
  34.  
  35. REM -- The variables below are set to year-month-day without separators (yyyymmdd)
  36. SET "today=%_year%%_month%%_day%" & REM today's date based on your selections above
  37. SET "compareDate=20180727" & REM the date you are comparing with today
  38.  
  39. REM -- Here's where the magic happens with comparing the two dates
  40. IF %compareDate% LSS %today% ECHO The comparison date is in the past.
  41. IF %compareDate% EQU %today% ECHO The comparison date is today.
  42. IF %compareDate% GTR %today% ECHO The comparison date is in the future.
  43. GOTO :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement