The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
arithmetic operation on two columns Jenny.palmy UNIX for Dummies Questions & Answers 1 05-04-2008 07:08 AM
Help with arithmetic operation emjayshaikh Shell Programming and Scripting 3 09-24-2007 12:44 AM
How to perform Date Intervals? yongho Shell Programming and Scripting 2 06-21-2005 12:02 PM
Yesterdays Date/Date Arithmetic Perderabo Answers to Frequently Asked Questions 0 04-26-2004 06:04 PM
Simple arithmetic operation paladyn_2002 Shell Programming and Scripting 2 04-19-2004 04:09 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-16-2008
agathaeleanor agathaeleanor is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 8
How to perform arithmetic operation on date

Hi all,

I would appreciate if anyone knows how to perform adding to date.
As for normal date, i can easily plus with any number.
But when it comes to month end say for example 28 Jun, i need to perform a plus with number 3, it will not return 1 Jul.

Thanks in advance for your help.
  #2 (permalink)  
Old 09-17-2008
subhendu81 subhendu81 is offline
Registered User
  
 

Join Date: Sep 2008
Location: mumbai
Posts: 78
hi,

u can try the following...

expr `date +%d` + 3

subhendu
  #3 (permalink)  
Old 09-17-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
That specifically does not solve the problem of wrapping at end of month. The FAQ section has a good thread on date arithmetic; see that instead. Yesterdays Date/Date Arithmetic
  #4 (permalink)  
Old 09-17-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 611
Try:

Use date -d as shown below:

Quote:
date -d "$var days "
Wed Sep 24 00:30:27 IST 2008
var=60
date -d "$var days "
Mon Nov 17 00:30:37 IST 2008
  #5 (permalink)  
Old 09-17-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,423
simply change TZ to change date..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0