Visit Our UNIX and Linux User Community


to find the diff in a date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting to find the diff in a date
# 1  
Old 08-04-2009
to find the diff in a date

Hello,

i have a variable where the present date is going to save.
and i have another variable where the another date which will of higher value is going to save.

I need to find the difference with respect to date,month and year.
What the need is to send an e-mail if the difference in dates is more than 25 days to a perticular team.

Requesting for assistance...


Thanks
Nag

Last edited by zaxxon; 08-04-2009 at 05:21 AM..
# 2  
Old 08-04-2009
You might want to convert both dates to epoch time (seconds since 01.01.1970) and then compare if the difference is greater than 60*60*24*25 seconds.
There are various ways to convert using for example a perl module, date -d if your date command supports this or strftime in gawk.

Try googling for "convert date epoch shell" where shell can be exchanged to your type of shell or awk/gawk or perl or...
There is also a lot of questions and answers on date arithmetics in this forum here. You might want to use the search function.

I'll change your subject since it is a bit confusing.
# 3  
Old 08-04-2009
Hi,

This sort of question crops up a lot, and there are a number of posts on this already.

I think you should find what you're looking for in the FAQ article:

https://www.unix.com/answers-frequent...rithmetic.html

HTH

Previous Thread | Next Thread
Test Your Knowledge in Computers #780
Difficulty: Easy
Bill Gates was born in Seattle, Washington, on October 28, 1945.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash diff date doesn't work

Hi everyone, I've an issue trying to soustracte two dates, e.g: d1=$(date -d "Nov 18, 2017" +%s) d2=$(date +%s) # Today we are 2017-11-16 echo "$(( (d1 - d2) / 86400 ))" Output: 1 I don't understand why it doesn't work. for me, it should give "18 - 16 = 2". Much appreciated... (1 Reply)
Discussion started by: Arnaudh78
1 Replies

2. Shell Programming and Scripting

Day/Hour diff between two date

Dear All I need to find out day diff between two dates. date -d or date -- day is not working in mine system. Currently i am using below code but it gives me wrong value while month change. IP: Date 1: 20150802 11:30:45 Date 2: 20150728 16:30:45 code used: awk '{t1=$2; t2=$4;... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies

3. UNIX for Dummies Questions & Answers

Find diff between two patterns in two files and append

Hi, I'm a newbie at programming in Unix, and I seem to have a task that is greater than I can handle. Trying to learn awk by the way (but in the end, i just need something that works). My goal is to compare two files and output the difference between the two. I've been reading, and I think I... (5 Replies)
Discussion started by: legato22
5 Replies

4. UNIX for Dummies Questions & Answers

efficient way to find diff

I have two files A and B. I want to create file C which is A - B. I am currently using grep -v -f B A > C Is there a more efficient way. Files A and B are both large files Thanks (3 Replies)
Discussion started by: chrisjones
3 Replies

5. Shell Programming and Scripting

Compare file timestamp with current date. Diff must be 1 hour.

Hello, I've created the script below to compare the content of two files with a delay of an hour. After an hour, the lines that exist in both files, will be printed and executed. The script now uses a counter to countdown 50 minutes. But what I would prefer is to check the file timestamp of... (3 Replies)
Discussion started by: taipan
3 Replies

6. Linux

diff date

Hi, One script is giving the date which is not contstant. and the need is to compare it with the current one and find the diff. if it is less than 15 days , need to send an e-mail. Date format coming from the script is October 24, 2055 Thanks (1 Reply)
Discussion started by: nagendramv
1 Replies

7. Shell Programming and Scripting

diff in date/time ?

the o/p is : Start Time: 2008-02-19 00:13:16,338 End Time: 2008-02-19 23:43:17,974 How to find the diff in time..........? (1 Reply)
Discussion started by: ali560045
1 Replies

8. UNIX for Advanced & Expert Users

Script to Find Diff from two folders

Hi I would like to find the diff between two folders: Ex: Folder:1 html.java go.java ten.java Folder:2html.java go.java ten.java you.java Questions comes: Folder:1 contains a files with old version, know the files were modified and updated with the new version in Folder2. I... (2 Replies)
Discussion started by: gkrishnag
2 Replies

9. UNIX for Dummies Questions & Answers

Help with date and time diff

Hi , Can somebody please help me with this. The date format is in MM/DD/YY HH24:MI:SS suppose I have a start_date=09/03/02 04:15:02 & Finish date= 09/04/02 07:13:51 I want to find out the difference between the two ie finish_time-start time. How can I do this. Morever I want the... (2 Replies)
Discussion started by: rooh
2 Replies

10. Shell Programming and Scripting

how to look in directory for files with diff date

What kind of command can i use to search a directory and subdirectories for all files that do not have the same date? i want to find any files that do not match a date of Sep 13, 2002? Or that have a different owner or group? Any help appreciated! (2 Replies)
Discussion started by: kymberm
2 Replies

Featured Tech Videos