Ksh Solaris Time calculation problem..Please help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ksh Solaris Time calculation problem..Please help
# 1  
Old 01-08-2010
Ksh Solaris Time calculation problem..Please help

I've gone through bunch of threads on time calculations but none of them helps on my problem

I've to get the time difference in HHMM format from following inputs

Input 1 :

01/08/2010 01:30
01/08/2010 03:20

Input 2 :

01/06/2010 22:00
01/07/2010 16:00

First input is easy but the second one is weird one...

Any idea? logic? anything please throw up and I will use it.

Last edited by prash184u; 01-08-2010 at 01:32 PM..
# 2  
Old 01-08-2010
Rolling your own date/time calculation is almost almost almost never a good idea. Either get the input in epoch seconds in the first place, or install something meant for the job.
# 3  
Old 01-08-2010
Thanks for your advice but it's not my choice....
# 4  
Old 01-08-2010
Tools From one of my earlier solutions....

Please see -->
https://www.unix.com/shell-programmin...ss-format.html

And note the following command -->
Code:
date +%s -d"2009-01-03"

Perhaps this might set you onto a path to solve your issue?
# 5  
Old 01-08-2010
Quote:
Originally Posted by joeyg
Please see -->
https://www.unix.com/shell-programmin...ss-format.html

And note the following command -->
Code:
date +%s -d"2009-01-03"

Perhaps this might set you onto a path to solve your issue?
That only works on GNU date, which Solaris is extremely unlikely to have.

I don't suppose there's mysql on your system? It has very nice date-handling abilities.
# 6  
Old 01-08-2010
Thanks Joey,

You are right Carona, it does not work in Solaris.

But everyone is welcome to give some ideas ... you never know anything could work....

Meanwhile i am working on my own algo. and making the script to calculate.. would be done by tomorrow.
# 7  
Old 01-08-2010
I had a function to do this but I've been unable to find it. Basically it went like this:

1. Convert each time into minutes (ex: 01:30 => 90)
2. Compare the start and end dates.
2a. If they are the same, then subtract the start minute from end minute.
2a. If not, then calculate the remaining minutes of the start time and call another
function that will find out how many days have passed inbetween. Keep track and
multiply that number by the number of minutes in a day (60*24). Then add in
the minutes from the end time to get the total number of minutes that elapsed.
3. Finally convert the total number of minutes back to HH:MM form.

Sorry I don't have the code for this but hopefully this helps with your logic.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Time calculation

Hi Gurus, I need to get one hour before time is yyyymmddhh format. ex. date +"%Y%m%d%H" gives 2017052814 but I need 2017052813 Thankx Please use CODE tags as required by forum rules! (6 Replies)
Discussion started by: nalakaatslt
6 Replies

2. Shell Programming and Scripting

Solaris Time Problem

Hi all, I am printing yesterday date in solaris using command: TZ=GMT+24 date +%b_%d_%Ybut at 01:00 AM on jan 11, it is printing: Anyone please explain. (1 Reply)
Discussion started by: anand2308
1 Replies

3. Shell Programming and Scripting

time calculation in ksh script

I"m trying to calculate the duration of of backup within a ksh shell script but I get an error. #!/bin/ksh STTIM=`date '+%T'` EDTIM=`date '+%T'` .... .... echo "DURATION OF BACKUP: $((EDTIM - STTIM))" (5 Replies)
Discussion started by: Bperl1967
5 Replies

4. Shell Programming and Scripting

KSH SHELL: problem calculation number of lines inside compressed file

Hi Gurus, I am working with a korn shell script to simplify some operations of calculation number of lines inside compressed file. The called function (inside a cycle) is the following: ######################################### # F.ne: CheckCount #########################################... (3 Replies)
Discussion started by: GERMANICO
3 Replies

5. Shell Programming and Scripting

Date time calculation

hello guys, I had been to many forums and many topics in this site as well for my question but did not get any solution. My question is how i can get y'day date with time stamp today is 20100729103819 and i am looking for output as 20100728103819. in simple words as we do in oracle sysdate-1... (4 Replies)
Discussion started by: lokaish23
4 Replies

6. Shell Programming and Scripting

Time stamp calculation

Hi all; I'm relatively new to scripting,I am working on a monitoring script.....where in i have to write subroutine which does the follows: It will check the time stamp of a file ( Oracle remarchive files) and compare it with existing time.If the time difference happen to be more than 90... (6 Replies)
Discussion started by: maverick_here
6 Replies

7. UNIX for Dummies Questions & Answers

Time Calculation

I have a file with over 100,000 lines of data with looking to compare times of about 2000 lines to get a total time of a process. The lines of unique data are as follows. FINER: CacSoapServer:reserveNetworkResource got the sessionID and INFO: Created CAC session ID The command... (5 Replies)
Discussion started by: bpfoster76
5 Replies

8. Shell Programming and Scripting

Time difference calculation

Hi Team, I am currently in the process of writing a script which will take a filename in the format SKADEV.0.db2.NODE0000.CATN0000.20080714231015.001 where the sixth string(with "." as the seperator) is the time stamp of the time of creation of the file. now here is my issue . I need to be... (2 Replies)
Discussion started by: Segwar
2 Replies

9. UNIX for Dummies Questions & Answers

Average completion time calculation?

I've been trying all night to come up with a script that will take a file that contains job completion times like this as input: 18:30 17:45 16:39 18:01 17:50 ... and figure the Average completion time. I've tried several things, and I just can't seem to get it to figure correctly. I'm... (5 Replies)
Discussion started by: Seawall
5 Replies

10. UNIX for Advanced & Expert Users

time calculation

Hi, I have start time as a string like 06:04:01 and end time like 06:05:01 i need do a simple math to get the duration. What is the best way to do this in Korn Shell scripting? Thanks (2 Replies)
Discussion started by: liux99
2 Replies
Login or Register to Ask a Question