If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Applications & Tools > DOS command syntax to get the day number of the current date

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-24-09, 04:48
LimaCharlie LimaCharlie is offline
Registered User
 
Join Date: Oct 2005
Posts: 119
DOS command syntax to get the day number of the current date

What is the dos command syntax to get the day of the current date.
For example today is Aug. 24, 2009, the day number should be 24.

I have a batch file wherein i need to know the day number.
Below is my sample command script:

IF %DATE% <= 7
(
echo Successful run: Email sent to users containing the final report file
)

ELSE

(
echo Error: Bugreport (Missing Report) email sent
)

Thanks.
Reply With Quote
  #2 (permalink)  
Old 08-24-09, 04:59
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 8,770
try google
or consider switching to vbscript as an alternative to dos batch
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 08-24-09, 07:24
LimaCharlie LimaCharlie is offline
Registered User
 
Join Date: Oct 2005
Posts: 119
This syntax returns the day number of the current date.

%Date:~0,2%

I used this in my IF condition, but when i tried running my batch file, i can't get the result.

@echo off

IF %Date:~0,2% > 8

(
echo PROCESS 3: successful >> test.log
echo. >> test.log
)

ELSE

(
echo PROCESS 4: failure>> test.log
echo. >> test.log
)

pause

:end
Reply With Quote
  #4 (permalink)  
Old 10-05-09, 23:42
AnanthaP AnanthaP is offline
Registered User
 
Join Date: May 2009
Location: India
Posts: 62
First off, I think, the arguments ~0,2 represent the positions and are dependant on the setting. Please check this out.

Secondly, > is a redirection symbol.
On XP, the batch command sysntax defines variables for string comparison. Help if at the comand prompt will give it to you.

Here is a sample batch file:
***********************************
@echo off
REM echo %%date:~0,2%
SET aa=%date:~0,2%
echo %aa%
If %aa% GTR 08 echo Greater than 8
If %aa% LEQ 07 echo Less than or equal to 7
echo.
If %aa% GTR 04 echo Greater than 4
If %aa% LEQ 03 echo Less than or equal to 3
***********************************

End
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On