Solved How do I make a batch file do this..

Hewlett-packard / Pavilion touchsmart amd a...
January 6, 2014 at 10:55:17
Specs: Any Windows OS, 8GB
Ok I need my batch file to echo the amount of time and days since a specific date and time. That's all I need.

message edited by Danm992

See More: How do I make a batch file do this..

Report •

January 6, 2014 at 19:53:20
✔ Best Answer
Essentially, you don't. In other words, batch is notorious for messing up "date math". I recommend either vbscript/jscript (native to windows) or powershell (3rd party) to handle this. Here's a stab at vbs approach:
'==== begin vbs: foll line is target date
x="1/1/2013 2:30 AM"
'or: x=wscript.arguments(0), where the argument is enclosed in dbl quotes.
z=datediff("d",x,date)&" "&datediff("h",x,date) mod 24
wscript.echo z

Report •

January 7, 2014 at 02:17:43
"That's all I need."

not quite

You need a useful description of the box.
not: "Windows OS"

As nbrane says, date math is no go in bat.

M2 Golden-Triangle

message edited by Mechanix2Go

Report •

January 17, 2014 at 14:34:31
In Unix Shell scripting, this kind of calculating eventually wasn't that difficult as I thought, and then I'm talking about the logic.

The code you need to use, is a pain on Windows CMD

Hi there.

Report •

Related Solutions

Ask Question