windows - How to create a batch program that will validate if date format entered is correct -


i need guys. doing batch program asks date in mm-dd-yyyy format (the dashes "-" included in user input) date added filenames of text files in folder. part easy me. don't know how make validation in program wherein user allowed input valid date (no letters) , limited 8 characters (since date has 8 numbers).

i don't know if possible in batch program, thing when program prompts user date, message displayed following:

`enter report date: mm/dd/yyyy` 

wherein mmddyyyy input field editable. slashes "/" displayed default not editable; serve separators month, day, , year user input. eliminate need include dashes "-" in user input (in current program).

after user has inputted date , program has validated format correct, date inputted added filenames of text files (as suffix) stored in folder. format of date added filenames mm-dd-yyyy means slashes "/" not included (since it's not allowed in filenames) , replaced dashes "-". can help!

check date function, if date valid:

@echo off &setlocal set "sdate=%date%"  set "ndate=07/22/2013" set "ndate=%ndate:/=-%" echo %ndate%|date >nul 2>&1 && echo "%ndate%" valid date || echo "%ndate%" not valid date set "ndate=17-22-2013" set "ndate=%ndate:/=-%" echo %ndate%|date >nul 2>&1 && echo "%ndate%" valid date || echo "%ndate%" not valid date set "date=%sdate%" pause 

..output is:

"07-22-2013" valid date "17-22-2013" not valid date 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -