| 1. |
Solve : Batch file: getting only the last 2 digits of the year? |
|
Answer» Like in: for /f "tokens=1-4 delims=/ " %%d in ("%date%") do @echo %%f%%e%%d I think they want DD/MM/YY Hey! I've GOT this radical new idea! Let's have a look at the thread title and the original post! Thread title Quote getting only the last 2 digits of the year Original post Quote I want only the 09 out of 2009Wow! that is radical!Radical or not it seems to me to be a better assumption that, based on the OP's script, the OP wants to return the date in either ddmmyy or mmddyy format. Quote from: Woodman on March 11, 2009, 04:24:15 PM Radical or not it seems to me to be a better assumption that, based on the OP's script, the OP wants to return the date in either ddmmyy or mmddyy format. You may be right, I think I had the sarcsam dial turned to 10 or 11. It's going to be 09 for about... Another like 280 days. Echo '09' Heck, I won't keep a batch file for a date for 1 year. Works for me.He's right. This must be for some other reason !Iunno if it works Code: [Select]if %date%==*/*/2009 echo 09 IDK if it does.It doesn't work. It gives me the statement after if and says this wasn't expected. It appears that you are trying to abuse the use of wild cards. They can not always be used in such a manner.Or even: if %date:~-4% gtr 2008 if %date:~-4% LSS 2010 echo %date:~-2% Someone will put us out of our misery shortly...(code deleted) since some people(s) might get offended if code create a .com executable. please accept my apology for any inconvenience caused. |
|