Sponsored Content
Full Discussion: comparing dates
Top Forums Programming comparing dates Post 78342 by jim mcnamara on Tuesday 19th of July 2005 10:04:41 AM
Old 07-19-2005
Start with man getdate, then use Lazzar's suggestion of difftime.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comparing 2 dates in Bourne shell

HI, I am able to find days difference using FIND command. However it is comparing between today and the last time it was modified. I now need to find the difference between a date specified by myself and the last time the file was modified. Is there a command which I can use or I have to... (1 Reply)
Discussion started by: scmay
1 Replies

2. Shell Programming and Scripting

comparing 2 dates

hi , I have two variables both containg dates, x= `date` and y= `date' their format being -> Fri Nov 12 22:59:50 MST 2004 how do I compare which one is greater. ->Can dates be converted into integer and then compared? ( one lengthy way would be to compare the words one by... (7 Replies)
Discussion started by: k_oops9
7 Replies

3. Shell Programming and Scripting

Comparing last modified dates

Hi All. Can someone please give me an example of how I'd do a comparison to find out if the last modified date of a file is newer than yesterday (i.e. today - 1 day)? Example: if ; then echo "Do something..." fi Any ideas or examples? Thanks. (1 Reply)
Discussion started by: dmilks
1 Replies

4. Shell Programming and Scripting

Comparing two dates

Hi, Can some one guide me how to compare two dates in unix. TIA Gupta (5 Replies)
Discussion started by: guptan
5 Replies

5. Shell Programming and Scripting

comparing dates

Hi guys I have a a variable called check_ts which holds a date value. this date value keeps refreshing every 15 minutes. I am going to start a cron job 5 minutes after the refresh. I have to check if the current date > 20 min of check_ts. how do i do that. thanks ragha (17 Replies)
Discussion started by: ragha81
17 Replies

6. UNIX for Dummies Questions & Answers

comparing two dates.

Hi I have yesterday date and todays date stored in two variables. Today date is stored in variable -- testdate=`date +%m/%d/%Y` I found the yesterday date and stored in variable -- ydate=$month'/'$day1'/'$year Now i am trying to find out whether $testdate is less that $ydate. I am... (6 Replies)
Discussion started by: intiraju
6 Replies

7. Shell Programming and Scripting

Comparing dates

Hi, I want to compare today's date(DDMMYYYY) with yesterday(DDMMYYYY) from system date,if (today month = yesterday month) then execute alter query else do nothing.One more condition is change of year also i.e today is Jan1 2012 and yesterday is Dec 31 2011. The above rek i want in Shell... (4 Replies)
Discussion started by: kumarmsk1331
4 Replies

8. Shell Programming and Scripting

Comparing Dates

Hi I'm trying to compare the current date (dd-Mmm-yyyy) against a variable that is an extracted date from an sql script. Below is the code: datenow=`date '+%d-%h-%Y'` #datenow is the current date in the format dd-Mmm-yyyy sqlplus $dbuserid/$dbpassword @ $SCRIPT_PATH/business-date.sql >... (3 Replies)
Discussion started by: joyAV
3 Replies

9. UNIX for Dummies Questions & Answers

about dates, comparing and calculation

Hi, can we do date comparisons in unix? like if i give the two dates find which date is old one and which is new one and difference between the two dates in terms of hours,minutes,days and months. (1 Reply)
Discussion started by: vmachava
1 Replies

10. Shell Programming and Scripting

Error while comparing dates

Hi I am failing to write a script which compares a list of dates in a file with today's date. OS: Solaris 10 I have a file which has server names & dates, i need to compare the date in this file with today's date, if it is less than today it should print the server name. code i tried is ... (3 Replies)
Discussion started by: nanz143
3 Replies
difftime(3)						     Library Functions Manual						       difftime(3)

NAME
difftime, difftime64 - Compares time values LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <time.h> double difftime( time_t time1, time_t time2); The following function declaration is a Compaq extension and does not conform to current standards. This function is provided to support the time64_t data type and is accessible only when the _TIME64_T feature macro is defined during compilation. #include <time.h> double difftime64( time64_t time64_1, time64_t time64_2); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: difftime(): XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies a time value of type time_t expressed in seconds. Specifies a time value of type time_t expressed in seconds. Specifies a time value of type time64_t expressed in seconds. Specifies a time value of type time64_t expressed in seconds. DESCRIPTION
The difftime() function returns a signed time value in seconds that is the difference between the values of the time1 and time2 parameters, also expressed in seconds. The difftime64() function works exactly as the difftime() function, but accepts arguments of type time64_t type instead of time_t. This function declaration is only available when the _TIME64_T feature macro is defined during compilation. See the time(3) reference page for additional details. NOTES
The difftime() and difftime64() functions are supported for multithreaded applications. RETURN VALUES
Upon successful completion the difftime() function returns a value, expressed in seconds, that is the difference between the values of parameters time1 and time2. Upon successful completion the difftime64() function returns a value,expressed in seconds, that is the difference between the values of parameters time64_1 and time64_2. RELATED INFORMATION
Functions: ctime(3), time(3), timezone(3) Standards: standards(5) delim off difftime(3)
All times are GMT -4. The time now is 04:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy