Need help on "VDATE" function

Hi,

I have a batch job which FTPs source feeds to the server. It has a function "VDATE" which is used to extract current date and it was used to add the date in the log file as suffix. Following is the code:

SET vdate=%mm%_%dd%_%yyyy%
set log_file=%working_dir%\Log_Files\log_%vdate%.log

It is working fine on my machine (adds the date in mm_dd_yyyy format)

But it is not working on client's machine (adds the date as dd__on_._)

I will appreciate if anyone helps me in solving this.....

Thanks

Are you sure this is UNIX? This looks more like a Windows batch file.

If it is Windows, those commands do not get the date: They use a date something else set earlier... Something earlier in the batch file should be setting these %mm% %dd% %yyyy% variables for them to be used.

No.....this is not Unix....I realized it is a windows batch file...I am pasting the complete code....this might help u in understanding the flow....

rem Create Date variable
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET vdate=%mm%_%dd%_%yyyy%

and the reason you've started this thread under 'UNIX for Dummies Questions & Answers' forum is....?

because I was not sure whether it comes under unix scripting or any other kind of script.

It's running the 'date' command, splitting it, and using chunks of it to fill yyyy, mm, and dd variables. It works okay on my windows XP system.

Older varieties of NT may not have had the same utilities or the same "for" syntax available. Different locales may also have a completely different date format which will also mess this up.

So it all comes down to how this batch file is being run, on what machine.