help in batch file, date problem
![]() ![]() ![]() ![]() ![]() |
help in batch file, date problem
|
|
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 ? |
|
|
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. |
|
|
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... |
|
|
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. |
|
|
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 |
|
|
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 |
|
|
|
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.
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 |
|
|
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 |
|
![]() ![]() ![]() ![]() |
| Lo-Fi Version | Time is now: 19th March 2010 - 01:51 AM |