Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Adding or subtracting days from current date in batch script  (Read 7882 times)

0 Members and 1 Guest are viewing this topic.

anand1773

  • Guest
Adding or subtracting days from current date in batch script
« on: September 06, 2010, 10:21:46 PM »
Hi,

I'm writing an batch file to create report

In the batch file iam passing two arguments:startdate and finishdate

Ex: startdate=07-sep-2009 finishdate=07-sep-2011

I need to have script that takes command line argument as input and gives me out currentdate last year and current date next year as mention above example.

currentdate-1 year & currentdate+ 1year

For example if I pass argument as 07-sep-2010 to batch script I should get ouput as startdate=07-sep-2009 finishdate=07-sep-2011.

Could any one please help?.

Regards,
Anand

ghostdog74



    Specialist

    Thanked: 27
    Re: Adding or subtracting days from current date in batch script
    « Reply #1 on: September 06, 2010, 10:43:03 PM »
    you can download coreutils for windows, then use the date command
    Code: [Select]
    c:\test> gnu_date.exe -d "1 year ago"
    c:\test> gnu_date.exe -d "1 year"