1.

Solve : Problem with variables?

Answer»

Okay. I'm making a simple alarm batch file. Then for the TIME, I want to extract the seconds from the %time% variable. Let me show you what I mean

6 : 5 2 : 4 8 . 5 2
1 2 3 4 5 6 7 8 9 10

So to get those I WOULD do this

Code: [Select]echo %time:~6,7 %


But it's giving me 6,7,8, and 9. COULD anyone explain how to fix this?

It sounds like you want
Code: [Select]echo %time:~6,2%In %VAR:~x,y%
x is the offset to start with
y is the length

It sounds like your understanding may have been that x,y was the RANGE to return, which is not QUITE correct.Okay, so is there a way to get only numbers 6 and 7Quote from: GuruGary on February 10, 2009, 06:29:39 AM

It sounds like you want
Code: [Select]echo %time:~6,2%


Discussion

No Comment Found