Lowyat.NET Forums

Welcome Guest ( Log In | Register )

 
RSS feedBump TopicReply to this topicStart new topicStart Poll

Outline · [ Standard ] · Linear+

> help in batch file, date problem

binqo89
post Nov 3 2009, 10:15 AM
Show posts by this member only |This post's rating (0+, 0-) | Post #1


Getting Started
**

Group: Junior Member
Posts: 82
Ratings earned: 0+, 0-
Ratings given: 0+, 0-

Joined: Aug 2008




@echo off
echo %date%, %time% > log_last.txt
echo Current date/time is %date%, %time%.
@pause
exit


this is my current code,
if lets say i would like to add in something like this :

if date > 01/11/2009 then
end
else
pause

anyone can help under this ?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
nxfx
post Nov 3 2009, 11:16 AM
Show posts by this member only |This post's rating (0+, 0-) | Post #2


Enthusiast
*****

Group: Senior Member
Posts: 834
Ratings earned: 0+, 0-
Ratings given: 0+, 0-

Joined: Jan 2003





i dont think you can compare dates using batch file.
better use C/C++ or vb.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
WaCKy-Angel
post Nov 3 2009, 11:19 AM
Show posts by this member only |This post's rating (0+, 0-) | Post #3


PeACe~~
*******

Group: Senior Member
Posts: 9,518
Ratings earned: 0+, 0-
Ratings given: 0+, 0-

Joined: Dec 2004
From: KL





QUOTE(binqo89 @ Nov 3 2009, 10:15 AM)
@echo off
echo %date%, %time% > log_last.txt
echo Current date/time is %date%, %time%.
@pause
exit
this is my current code,
if lets say i would like to add in something like this :

if date > 01/11/2009 then
  end
else
  pause

anyone can help under this ?
*


If u want to do something like delete a file if its older than xx days then there is another way, but sorry i cant recall how...
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
binqo89
post Nov 3 2009, 11:21 AM
Show posts by this member only |This post's rating (0+, 0-) | Post #4


Getting Started
**

Group: Junior Member
Posts: 82
Ratings earned: 0+, 0-
Ratings given: 0+, 0-

Joined: Aug 2008




convert date to string ?
like 11/03/2009 to 11032009?
then compare it with 11012009?
isit possible ? how to convert it ?

i just want this .bat file to run in startup and check for the date of each of my computer.
if the date is not bigger than lets say nov of 2009, the .bat file will pause there.
else it will exit.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
ketnave
post Nov 3 2009, 11:27 AM
Show posts by this member only |This post's rating (0+, 0-) | Post #5


Getting Started
**

Group: Junior Member
Posts: 84
Ratings earned: 0+, 0-
Ratings given: 0+, 0-

Joined: Sep 2009




you could try writting in vbs instead, and call the vbs from your bat file.

vbs have greater support for date comparison
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
binqo89
post Nov 3 2009, 11:39 AM
Show posts by this member only |This post's rating (0+, 0-) | Post #6


Getting Started
**

Group: Junior Member
Posts: 82
Ratings earned: 0+, 0-
Ratings given: 0+, 0-

Joined: Aug 2008




QUOTE(ketnave @ Nov 3 2009, 11:27 AM)
you could try writting in vbs instead, and call the vbs from your bat file.

vbs have greater support for date comparison
*


i got no idea how to do this, even a small batch file took me a while morning.
any better suggestion?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
cute_boboi
post Nov 3 2009, 12:45 PM
Show posts by this member only |This post's rating (0+, 0-) | Post #7


° 忍 °
*******

Group: Senior Member
Posts: 3,450
Ratings earned: 0+, 0-
Ratings given: 0+, 0-

Joined: Nov 2004
From: [Latitude-N3°9'25"] [Longtitude-E101°42'45"]





Old school batch programming. Things were not as easy and GUI friendly as OO. rolleyes.gif

CODE
@echo off
if %DATE:~10,4%%DATE:~4,2%%DATE:~7,2% LSS 20091104 goto else
echo "bigger"
goto endif
:else
echo "smaller"
:endif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
binqo89
post Nov 3 2009, 01:47 PM
Show posts by this member only |This post's rating (0+, 0-) | Post #8


Getting Started
**

Group: Junior Member
Posts: 82
Ratings earned: 0+, 0-
Ratings given: 0+, 0-

Joined: Aug 2008




QUOTE(cute_boboi @ Nov 3 2009, 12:45 PM)
Old school batch programming. Things were not as easy and GUI friendly as OO.  rolleyes.gif

CODE
@echo off
if %DATE:~10,4%%DATE:~4,2%%DATE:~7,2% LSS 20091104 goto else
echo "bigger"
goto endif
:else
echo "smaller"
:endif

*



woah ! thanks alot! thats exactly what i need ! notworthy.gif notworthy.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Bump TopicReply to this topicTopic OptionsStart new topic
 

Lo-Fi Version Time is now: 19th March 2010 - 01:51 AM
All Rights Reserved 2003-2009 Vijandren Ramadass (~living on a prayer~)