The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Compare date from db2 table to yesterday's Unix system date sasaliasim Shell Programming and Scripting 8 04-24-2008 03:04 AM
Perl: Extracting date from file name and comparing with current date MKNENI Shell Programming and Scripting 4 03-26-2008 01:01 PM
date subtraction(URGENT) uday123 Linux 3 02-25-2008 05:14 AM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 05:42 PM
Date Subtraction in KSH mharley Shell Programming and Scripting 3 03-03-2005 08:17 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 06-19-2007
Registered User
 

Join Date: May 2007
Posts: 14
subtraction from date

hi gurus!
i realize that my question shows my stupidness, but i need your help!

i have:
s_date=`date +%m-%d-%Y_%I%p`
variable and i need the same, but minus one hour..
what i made:
s_date=time(`date +%m-%d-%Y_%I%p`) - 3600

but i'm getting:
daily_exports.sh: line 20: syntax error near unexpected token `('
daily_exports.sh: line 20: `new_date=time()-3600'

also i did:
new_date=time()-3600
s_date=strftime(`date +%m-%d-%Y_%I%p`, new_date);

etc.. nothing works,
please, help!

Thank you beforehand,
Maria.
Reply With Quote
Forum Sponsor
  #2  
Old 06-19-2007
Shell_Life's Avatar
Registered User
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Maria,
Date calculation can be very involved as you have to consider
end of month, end of year, leap year, etc.
Here is a thread that can help you in this issue:
http://www.unix.com/answers-to-frequ...rithmetic.html
Reply With Quote
  #3  
Old 06-19-2007
Registered User
 

Join Date: May 2007
Posts: 14
Oh, thank you for your help!
this is great source!

Thanks,
Maria.
Reply With Quote
  #4  
Old 06-19-2007
Registered User
 

Join Date: May 2007
Posts: 14
still fighting. I'll really appreciate any help.
thank you,
M.
Reply With Quote
  #5  
Old 06-19-2007
Registered User
 

Join Date: May 2007
Posts: 14
cool, i found!
date -d "-1 hour"
works pefectly,
thank you!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0