Shell script to calculate difference between 2 dates


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to calculate difference between 2 dates
# 1  
Old 12-06-2012
Shell script to calculate difference between 2 dates

shell script to calculate difference between 2 dates
# 2  
Old 12-06-2012
some hints for you:

calculate by epoc
# 3  
Old 12-06-2012
Check this thread created by Perderabo
# 4  
Old 12-08-2012
Or this thread.
Using ksh printf builtin
or
shell function
or
using GNU date command
or
Perl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to calculate difference of split and sum the difference

In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13. I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (2 Replies)
Discussion started by: cmccabe
2 Replies

2. Shell Programming and Scripting

Difference in dates in days (ksh shell)

Hi Guys, Need a small help, how do i get the difference between two dates (in days) in KSH shell My date is in mm/dd/YYYY format, Is there a function to get time stamp from the respective date and time ( mm/dd/yyyy HH:MM:SS) (1 Reply)
Discussion started by: selvankj
1 Replies

3. Shell Programming and Scripting

Calculate time difference between pst and pdt dates in perl

Hi, how to calculate the time difference between PST date and PDT date in perl scripting. date1: Mon Dec 31 16:00:01 PST 2015 date2: Tue Mar 19 06:09:30 PDT 2013 and also difference between PST-PST and PDT-PDT need difference in months or days (months prefereble). (3 Replies)
Discussion started by: praveen265
3 Replies

4. Shell Programming and Scripting

How to Calculate the difference between two dates?

I want the difference between two following date using scripts in terms of no.of days. How I can accomplish this. lastdate=Tue Nov 13 10:30:56 2012 currdate=Wed Dec 15 15:58:21 PAKST 2012 Ouput should be like this: Your Password will expire after = 32 Days on Wed Dec 15 15:58:21 PAKST... (1 Reply)
Discussion started by: m_raheelahmed
1 Replies

5. Shell Programming and Scripting

Calculate the number of days between 2 dates - bash script

I wrote the day calculator also in bash. I would like to now, that is it good so? #!/bin/bash datum1=`date -d "1991/1/1" "+%s"` datum2=`date "+%s"` diff=$(($datum2-$datum1)) days=$(($diff/(60*60*24))) echo $days Thanks in advance for your help! (3 Replies)
Discussion started by: kovacsakos
3 Replies

6. Web Development

Calculate the number of days between 2 dates - PHP

Is this code good for this purpose? <?php $date1 = mktime(0,0,0,01,01,1991); $date2 = mktime(0,0,0,03,22,2012); $diff = $date2 - $date1; $days = $diff / (60*60*24); echo ($days . "<br />"); ?> (3 Replies)
Discussion started by: kovacsakos
3 Replies

7. Shell Programming and Scripting

Calculate days between yyyyMmmdd dates on Solaris

I extract dates from the log file and need to calculate days between two dates. My dates are in yyyyMmmdd format. Example: $d1=2011 Oct 21 $d2=2012 Feb 20 I need to calculate the number of days between $d2 and $d1. This is on Solaris. Any ideas? Thanks, djanu (4 Replies)
Discussion started by: djanu
4 Replies

8. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

9. Shell Programming and Scripting

Difference of 2 dates in shell script

Hi., After retrieving values from DB I have two datestamps in format: 12/01/2010:05:40:00 AM and 12/01/2010:06:00:00 PM. general time format: MM/DD/YYYY:HH:MM:SS AM or PM Any quick solution to get the difference of two in the format : 1 day(s) 12:20:00 Thanks., (6 Replies)
Discussion started by: IND123
6 Replies

10. Shell Programming and Scripting

How to calculate specific hours between 2 dates

Hi there, I am trying to find out a way to calculate how many hours are between 2 dates but from a specific time range, actually working hours (Monday to Friday 09:00 - 18:00). What I mean is for example date1 = Monday 21 July 2008 22:00:00 so in python 2008-07-21 22:00:00 date2 = Wednesday... (5 Replies)
Discussion started by: sickboy
5 Replies
Login or Register to Ask a Question