Sponsored Content
Special Forums Windows & DOS: Issues & Discussions Adding or subtracting days from current date in batch script Post 302487464 by Leo Gutierrez on Wednesday 12th of January 2011 02:38:21 PM
Old 01-12-2011
Code:
@echo off
setlocal enabledelayedexpansion
if "%1" == "" (
	echo Error
	exit /b 1
)

for /f "tokens=1,2,3 delims=-" %%a in ("%1") do (
	set /a yearStart=%%c - 1
	set "startdate=%%a-%%b-!yearStart!"
	set /a yearFinish=!yearStart! + 2
	set "finishDate=%%a-%%b-!yearFinish!"
)
echo Start : !startdate!
echo Finish : !finishDate!


Code:
C:\>code.bat 07-sep-2010
Start : 07-sep-2009
Finish : 07-sep-2011

C:\>

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

subtracting a days from current date

Hi i am trying to subtract days from current date. For example todays date is 10/03/2006. If i subtract 2 days it should give 8/03/2006. I am also trying to find the access date of a file in dd/mm/yyyy format. Can any one please help in how to do this. Ramesh (1 Reply)
Discussion started by: rameshspal
1 Replies

2. UNIX for Dummies Questions & Answers

adding or subtracting days in the o/p of date

how can we add or subtract days from the output of date command in unix... like if i want to subtract a day from the result of date command like this.. v_date=`date +%Y%m%d` this wud give me 20080519 now i want to subtract one day from this.. so tht it wud give me 20080518.. how do i do... (1 Reply)
Discussion started by: St.Fartatric
1 Replies

3. Shell Programming and Scripting

how to get what date was 28 days ago of the current system date IN UNIX

Hi, Anybody knows how to get what date was 28 days ago of the current system date through UNIX script. Ex : - If today is 28th Mar 2010 then I have to delete the files which arrived on 1st Mar 2010, (15 Replies)
Discussion started by: kandi.reddy
15 Replies

4. Shell Programming and Scripting

How to Get 60 days Old date from current date in KSH script

Hi i am writing a cron job. so for it i need the 60 days old date form current date in variable. Like today date is 27 jan 2011 then output value will be stote in variable in formet Nov 27. i am using EST date, and tried lot of solution and see lot of post but it did not helpful for me. so... (3 Replies)
Discussion started by: Himanshu_soni
3 Replies

5. Shell Programming and Scripting

Number of days between the current date and user defined date

I am trying to find out the number of days between the current date and user defined date. I took reference from here for the date2jd() function. Modified the function according to my requirement. But its not working properly. Original code from here is working fine. #!/bin/sh... (1 Reply)
Discussion started by: hiten.r.chauhan
1 Replies

6. Shell Programming and Scripting

Substracting days from current date(K shell script)

Hi, I want to subtract 'n' days from the current timestamp in a k shell script. Is there any inbuilt function to do it or any workaround solution to get the date. And I want the output to be in YYYY:MM:DD HH:MM:SS format. Please help. Thanks in advance. (4 Replies)
Discussion started by: Suryaaravindh
4 Replies

7. UNIX for Dummies Questions & Answers

Static date adding and subtracting years

Hi Gurus! I have a static date in a YYYYMMDD format; and I want get the date 2 years in the past and 2 years in the future. static_date=20010203 old_date=$static_date - 3 years future_date=$static_date + 2 years I was only able to research on dates that are current and not on static... (3 Replies)
Discussion started by: kokoro
3 Replies

8. Shell Programming and Scripting

Adding/ Subtracting from Date

Hi , How can I add/substruct x number of days with date? For example My_Date=`date` Now I need Hope it's clear. (2 Replies)
Discussion started by: Anupam_Halder
2 Replies

9. UNIX for Dummies Questions & Answers

Subtracting number of days from current date

Hi All, I am using KSH shell and need to subtract n number of days from the current date .. kindly suggest ! Thanks in advance!:) (20 Replies)
Discussion started by: dev.devil.1983
20 Replies

10. HP-UX

awk command in hp UNIX subtract 30 days automatically from current date without date illegal option

current date command runs well awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat subtract 30 days fails awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies
LedgerSMB::Batch(3pm)					User Contributed Perl Documentation				     LedgerSMB::Batch(3pm)

NAME
LedgerSMB::Batch - Batch/voucher management model for LedgerSMB 1.3 SYNOPSIS
Batch/voucher management model for LedgerSMB 1.3 METHODS
get_new_info This gets the information required for the new batch screen. Currently this just populates the batch_number hashref value. create Saves the batch info and populates the id hashref value with the id inserted. delete_voucher($id) Deletes the voucher specified by $id. get_search_criteria Sets all hash values needed for the search interface: batch_classes List of all batch classes batch_users List of all users get_search_method (private) Determines the appropriate search method, either for empty, mini, or full searches Returns the appropriate stored proc name. get_search_results Returns the appropriate search as detected by get_search_method. get_class_id($type) Returns the class_id of batch class specified by its label. post Posts a batch to the books and makes the vouchers show up in transaction reports, financial statements, and more. delete Deletes the unapproved batch and all vouchers under it. list_vouchers Returns a list of all vouchers in the batch and attaches that list to $self->{vouchers} get Gets the batch and merges information with the current batch object. Copyright (C) 2009, The LedgerSMB core team. This file is licensed under the Gnu General Public License version 2, or at your option any later version. A copy of the license should have been included with your software. perl v5.14.2 2012-03-26 LedgerSMB::Batch(3pm)
All times are GMT -4. The time now is 04:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy