![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-08 22:09 |
47,811 topics / 349,895 posts / today 0 new / 48,253 members |
| DOS批处理 & 脚本技术(批处理室) » How to get the date N days earlier |
| Printable Version 1,016 / 3 |
| Floor1 yaootaa | Posted 2008-05-23 17:38 |
| 新手上路 Posts 3 Credits 10 | |
|
If the current date returned by date is 2008-05-23, then under DOS how can I get the date N days earlier, for example 2 days earlier would be 2008-05-21
|
|
| Floor2 lxmxn | Posted 2008-05-24 15:01 |
| 版主 Posts 4,938 Credits 11,386 | |
|
Does the DOS you mean refer to the DOS system or the CMD environment?
|
|
| Floor3 jiulong | Posted 2008-05-26 15:29 |
| 中级用户 Posts 183 Credits 396 | |
|
@echo off
set a=%date:~0,4% set b=%date:~5,2% set/a c=%date:~8,2%-2 echo The date two days earlier is: %a% year %b% month %c% day pause If this solves it, give me some credits ah [ Last edited by jiulong on 2008-5-26 at 09:03 PM ] |
|
| Floor4 easonL | Posted 2008-05-30 15:04 |
| 初级用户 Posts 56 Credits 118 From 南京 | |
Originally posted by jiulong at 2008-5-26 03:29 PM: What date is two days before the 1st? The poster above, stop kidding around. Doing it like this will mislead us newbies, hehe, just joking~~ don't mind it I suggest the OP search carefully, there are still quite a lot of posts with the answer, but calculating the date N days earlier is still rather complicated, leap months and all that (for me it's rather difficult too, I'm still learning as well) |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |