Sponsored Content
Top Forums UNIX for Dummies Questions & Answers While we are on the subject of dates. Another date question Post 7054 by MizzGail on Tuesday 18th of September 2001 09:20:42 AM
Old 09-18-2001
I have that information.
I am not looking for logical approaches....
I am looking for the technical way of how do I subtract the start time from the end time to get the time span?

I have the time 08:30:00 how do I write script code to subtract it from 08:47:00 ???????????

I can awk out the hour and minutes and seconds and work that way then put it all back together, but I want to know if anyone has an easier way to calculate elapsed time.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

using 'date' to get previous days' dates

I am familiar with using the 'date' command to get the current date but I have a situation where I need to get the previous day's date as well as the date two days prior. Theoretically I could use 'expr' to compute these values but I need it to work in instances where the previous month's dates... (2 Replies)
Discussion started by: slant-40
2 Replies

2. Shell Programming and Scripting

Display the last five dates from the given date

Hi all, In Oracle we have got sysdate -1 to find the previous date. Is there any similar way to display date in unix shell scripting? Kindly help me to display the last five dates from the given date Thanks, Geetha (11 Replies)
Discussion started by: iamgeethuj
11 Replies

3. Shell Programming and Scripting

Generate quarter dates with begin date and end date

Hi All, I am trying to generate quarter dates with user giving input as begin date and end date. Example: Input by user: begin_date = "2009-01-01" end_date = 2010-04-30" required output: 2009-01-01 2009-03-31 09Q01 2009-04-01 2009-06-30 09Q02 . . till 2010-01-01 2010-03-31 10Q01 ... (9 Replies)
Discussion started by: sol_nov
9 Replies

4. Solaris

Date after 5 dates in YYYYMMDD format

Hi Experts, How to get date 5 days after current date in YYYYMMDD format? How do we compare date in YYYYMMDD format? Thanks (1 Reply)
Discussion started by: needyourhelp10
1 Replies

5. Shell Programming and Scripting

Using 'date' to list a range of dates

Hi guys, I have been trying to create a list of dates from a certain range, ie. range from 01011950 to 31122000 But when my below code reaches certain dates, it comes up with a; 'date: invalid date 'yyyy-mm-dd -d 1day' Sofar I have come up with the following, slow and ugly; ... (4 Replies)
Discussion started by: TAPE
4 Replies

6. Shell Programming and Scripting

Need to capture all dates between start date and End date.

Hi All, I enter Start date and end date as parameters. I need to capture dates between start date and end date. Please let me know if you have any idea the same. Thanks in advance. Nagaraja Akkivalli. (5 Replies)
Discussion started by: Nagaraja Akkiva
5 Replies

7. Shell Programming and Scripting

Need to capture dates between start date and end date Using perl.

Hi All, Want to get all dates and Julian week number for that date between the start date and end date. How can I achive this using perl? (To achive above functionality, I was connecting to the database from DB server. Need to execute the same script in application server, since databse... (6 Replies)
Discussion started by: Nagaraja Akkiva
6 Replies

8. Shell Programming and Scripting

ksh compare dates INSIDE a file (ie date A is > date B)

In KSH, I am pasting 2 almost identical files together and each one has a date and time on each line. I need to determine if the first instance of the date/time is greater than the 2nd instance of the date/time. If the first instance is greater, I just need to echo that line. I thought I would... (4 Replies)
Discussion started by: right_coaster
4 Replies

9. UNIX for Advanced & Expert Users

Date between 2 dates

Hi All, Can you help me in finding the business dates (Mon-Fri) between two date ranges.. (forget abt holidays in weekdays) searched and tried a lot but cant figure this. ISs there any special function availble in unix for this (5 Replies)
Discussion started by: Deena1984
5 Replies

10. UNIX for Beginners Questions & Answers

Splitting week start date and end date based on custom period start dates

Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below. Could you please help out to achieve solution through shell script.. File content: ... (2 Replies)
Discussion started by: nani2019
2 Replies
TIMEVAL(3)						   BSD Library Functions Manual 						TIMEVAL(3)

NAME
timeval, timespec, itimerval, itimerspec, bintime -- time structures SYNOPSIS
#include <sys/time.h> void TIMEVAL_TO_TIMESPEC(struct timeval *tv, struct timespec *ts); void TIMESPEC_TO_TIMEVAL(struct timeval *tv, struct timespec *ts); DESCRIPTION
The <sys/time.h> header, included by <time.h>, defines various structures related to time and timers. 1. The following structure is used by gettimeofday(2), among others: struct timeval { time_t tv_sec; suseconds_t tv_usec; }; The tv_sec member represents the elapsed time, in whole seconds. The tv_usec member captures rest of the elapsed time, represented as the number of microseconds. 2. The following structure is used by nanosleep(2), among others: struct timespec { time_t tv_sec; long tv_nsec; }; The tv_sec member is again the elapsed time in whole seconds. The tv_nsec member represents the rest of the elapsed time in nanosec- onds. A microsecond is equal to one millionth of a second, 1000 nanoseconds, or 1/1000 milliseconds. To ease the conversions, the macros TIMEVAL_TO_TIMESPEC() and TIMESPEC_TO_TIMEVAL() can be used to convert between struct timeval and struct timespec. 3. The following structure is used by setitimer(2), among others: struct itimerval { struct timeval it_interval; struct timeval it_value; }; 4. The following structure is used by timer_settime(2), among others: struct itimerspec { struct timespec it_interval; struct timespec it_value; }; Both struct itimerval and struct itimerspec are used to specify when a timer expires. Generally, it_interval specifies the period between successive timer expirations. A value zero implies that the alarm will fire only once. If it_value is non-zero, it indicates the time left to the next timer expiration. A value zero implies that the timer is disabled. 5. The following structure is used by bintime(9), among others: struct bintime { time_t sec; uint64_t frac; }; The sec member specifies the time in seconds and frac represents a 64-bit fraction of seconds. The struct bintime is meant to be used in the kernel only. It is further described in timecounter(9). EXAMPLES
It can be stressed that the traditional UNIX timeval and timespec structures represent elapsed time, measured by the system clock (see hz(9)). The following sketch implements a function suitable for use in a context where the timespec structure is required for a conditional timeout: static void example(struct timespec *spec, time_t minutes) { struct timeval elapsed; (void)gettimeofday(&elapsed, NULL); _DIAGASSERT(spec != NULL); TIMEVAL_TO_TIMESPEC(&elapsed, spec); /* Add the offset for timeout in minutes. */ spec->tv_sec = spec->tv_sec + minutes * 60; } A better alternative would use the more precise clock_gettime(2). SEE ALSO
timeradd(3), tm(3), bintime_add(9) BSD
April 12, 2011 BSD
All times are GMT -4. The time now is 08:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy