Computing.Net > Forums > Programming > Dos Batch File

Dos Batch File

Reply to Message Icon

Original Message
Name: daj0pe
Date: July 25, 2006 at 23:57:13 Pacific
Subject: Dos Batch File
OS: xp/2000
CPU/Ram: -
Model/Manufacturer: -
Comment:

can somebody please help me create a batch file, that will tell you the date, 120 days from today? thanks


Report Offensive Message For Removal


Response Number 1
Name: Shr0Om
Date: July 26, 2006 at 00:45:14 Pacific
Reply: (edit)

Perhaps it can be done, but it would be a complex task to write it in a batch. I recomend you to consider some other language for this task.


Report Offensive Follow Up For Removal

Response Number 2
Name: dtech10
Date: July 26, 2006 at 16:03:17 Pacific
Reply: (edit)

Hi
I wrote a batch file to do date calculations , but I need your date format and if you want the weekday as well.
What doe's the "date /t" command produce on your system.


Report Offensive Follow Up For Removal

Response Number 3
Name: Shr0Om
Date: July 27, 2006 at 07:33:24 Pacific
Reply: (edit)

dtech10: Heheh, neat..
Would you post the code?


Report Offensive Follow Up For Removal

Response Number 4
Name: dtech10
Date: July 27, 2006 at 15:44:30 Pacific
Reply: (edit)

Hi Shr0m
@echo off
rem You may have to modify the dd mm yy variables to
rem suit your system date.
rem I've left out the weekday calculation to make it slightly
rem less complex. I add it if required.
rem I'm english so my date variable=dd/mm/yyyy WinXp
rem youre's I'm guessing would be Thu mm/dd/yyyy Win2000

rem === Get Date Variables ===
for /f "tokens=1-4 delims=/-" %%a in ('date /t') do (
set wk=%%a
set mm=%%b
set dd=%%c
set yy=%%d
)
rem === Calulate Julian Date ===
set mo=%mm%
set yr=%yy%
if %mm% LSS 3 (
set /a mo=%mo%+12
set /a yr=%yr%-1
)
set /a mo=%mo%+1
set /a a=%yr%/100
set /a b=2-%a%+%a%/4
set /a jd=%yr%*36525/100+%mo%*306001/10000+%dd%+%b%-694084

rem === Todays Date ===
set Today=%dd%/%mm%/%yy%

rem === Add 120 to Julian Date ===
set /a jd=%jd%+120

rem === Recalculate Julian Date back into a date ===
set /a yy=%jd%*100/36525
set /a dd=%jd%-%yy%*36525/100
set /a mm=%dd%*10/306
set /a dd=%dd%-(%mm%*306+5)/10
if %dd%==0 (
set dd=31
set /a mm=%mm%-1
if %mm%==0 set dd=29
)
set /a mm=%mm%+3
if %mm% GTR 12 (
set /a mm=%mm%-12
set /a yy=%yy%+1
)
set /a yy=%yy%+1900

rem === Add leading zero if needed ===
if %dd% LSS 10 set dd=0%dd%
if %mm% LSS 10 set mm=0%mm%
set Day120=%dd%/%mm%/%yy%

rem Display Dates ===
echo Today Date=%Today%
echo Today+120 Days=%Day120%

rem === Clear Variables ===
for %%a in (a b wd dd mm yd yy jd mo yr) do set %%a=



Report Offensive Follow Up For Removal

Response Number 5
Name: bstansel
Date: September 25, 2006 at 14:35:42 Pacific
Reply: (edit)

I have also located your other posting on http://www.tech-recipes.com/batch_f...

Could you explain why your calculated julian date is 60 days earlier than what Microsoft Excel calculates the serial date from Jan 1, 1900 to be? Would you please also reference the source of your formula.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Dos Batch File

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge