|
Answer» @ECHO OFF @For /F "tokens=2,3,4 delims=/ " %%A in ('DATE /t') do @( Set Month=%%A Set Day=%%B Set Year=%%C @echo TODAY = %%B/%%A/%%C ) @echo TODAY =%DAY%/%Month%/%Year%
02/03/2016
FOR /F "tokens=2 delims==" %%A in (C:\Table\location.txt do ( FOR /F "skip=1 tokens=1,7,8,9 delims=," %%S in (C:\Temp\Mylists\%%A.csv) do ( rem Day=%%V Month=%%U Year=%%T echo %%A,%%S,%%V/%%U/%%T >> C:\Temp\test.csv ))
7/2/2016 1/3/2016
to compare date ( no time) if compare LEQ - less than or equal How do I solve the problem with the leading Zero
ThanksThis will pad a number in a for variable
Code: [Select]if %%z LSS 10 echo 0%%zthanks foxidrive but...
FOR /F "skip=1 tokens=1,7,8,9 delims=," %%S in (ariel.csv) do ( rem Day=%%V Month=%%U Year=%%T echo DATE FOME READING FILE - %%V/%%U/%%T
csv file Date I do not have the option to change the file format 7/2/2016
@ if %%V LSS 10 echo 0%%V @ if %%U LSS 10 echo 0%%U echo is ok - But I should compare dates for today
I tried if %%U LSS set %%V=0%%V Without success
I have to compare less than or equal And it's still wrong 7/2/2016 LEQ 04/03/2016
frome file i get 7/2/2016 frome system 04/03/2016You need to juggle the dates into yyyymmdd order and that can easily be compared.
Without seeing the DATA it's hard to give code that is suitable.This is the output I get software that I can not change - csv file When reading the file with the command LINE date is Without leading Zero
I have to do EXACTLY what you wrote yymmdd but I do not know how to do that with the command line Get today's date and the date of the file in the same format
[attachment deleted by admin to conserve space]Test this with your sample data. Line one isn't excluded at this stage.
Code: [Select]@echo off rem The four lines below will give you reliable YY DD MM YYYY HH Min Sec MS variables in XP Pro and higher. for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" & set "MS=%dt:~15,3%" set "datestamp=%YYYY%%MM%%DD%"
setlocal enabledelayedexpansion for /f "usebackq tokens=4,5,6,9,10,11 delims=," %%a in ("c:\folder\file.csv") do ( if %%a LSS 10 (set day1=0%%a) else (day1=%%a) if %%b LSS 10 (set mon1=0%%b) else (mon1=%%b) set year1=%%c
if %%d LSS 10 (set day2=0%%d) else (day2=%%d) if %%e LSS 10 (set mon2=0%%e) else (mon2=%%e) set year2=%%f
echo Today is %datestamp% echo term 1 is !year1!!mon1!!day1! echo term 2 is !year2!!mon2!!day2! ) pause
|