How do i minus two dates and send email?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do i minus two dates and send email?
# 1  
Old 07-01-2014
How do i minus two dates and send email?

Unix Gurus,

I am using oracle11g database with Red hat Linux.

Here is what i need help..

If this query return more than 2 ,then i need to send the page to group.

Code:
select (sysdate - (sysdate-60*(1/1440)))*24 from dual;

Can you please past me some sample code to achieve this through shell script?

Last edited by Scott; 07-01-2014 at 06:43 PM.. Reason: Code tags
# 2  
Old 07-02-2014
Had you mentioned what you have tried, it would have been helpful

Code:
sqlplus -s ${USERNAME}/${PASSWORD}@${DBNAME} <<! | read hrs
set feed off
set pages 0
select (sysdate - (sysdate-60*(1/1440)))*24 from dual;
exit;
!
if [[ ${hrs} -gt 2 ]]; then
## Write what you wanted to do if output is greater than 2
fi

# 3  
Old 07-02-2014
Will this not always return the same value? Ignoring the date part, you are asking it to give you (x-(x-60*(1/1440)))*24

My maths would suggest that x is redundant and you are left with the numerical-only calculation of (60*(1/1440))*24 or (24*60)/1440 = 1

Am I missing something?

What is the logic you are trying to implement?



Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. SuSE

Send outgoing email to my GroupWise email

Dear users, I have Linux server whose versions are Suse 10 SP 3 and Suse 11. I am trying to send email from these servers to my GroupWise email account. In /etc/postfix/main.cf file, The current value of MYHOSTNAME is LINUX.LOCAL. What should be the right value of MYHOSTNAME? Is... (0 Replies)
Discussion started by: JDBA
0 Replies

2. Shell Programming and Scripting

Compare the dates and send mail

Hi Guys, I am new to this fourm. Need your help to complete my requirment. Below is my requirment. Have to check expiry of the certificate. Compare the certificate expiry date with current date. If the difference is less than 30 days, need to send mail. #!/usr/bin/ksh... (2 Replies)
Discussion started by: rameshchukka
2 Replies

3. UNIX and Linux Applications

sqlite: calculating with dates - compare current date minus 6 months with stored record

Hi I have a table with name, date in format DD.MM.YYYY. I need to something like this (I try to explain in pseudo code) if SYSDATE (current date) minus 6 months > $expiry date print OK else print NOK with $name and $expiry date I know this is possible with Oracle. How to do this... (0 Replies)
Discussion started by: slashdotweenie
0 Replies

4. UNIX for Dummies Questions & Answers

new to ldap, send email to a ou or group, and see a list from email client

hi, i'm running openldap on ubuntu 10.04, creating new items with apache directory studio (windows version). i use the ldap just as an address book to our small office (email clients are windows live mail 2009, 2011, microsoft outlook 2007 and 2010). a. i cant see a list of the contacts,... (0 Replies)
Discussion started by: V4705
0 Replies

5. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

6. Solaris

Send an email from Solaris using Linux email server

Hello everyone I have a problem and I need your help: I have a Solaris 10 and Solaris 8 UNIX Servers, and Linux Centos4 as email server. I need send an email from Solaris servers preferably using Centos4 email server. I have no mail service configured in my Solaris computers (1 Reply)
Discussion started by: aflores
1 Replies

7. UNIX for Dummies Questions & Answers

Send email where # is in the email address - Using Unix

Hi All, How do I send an email using malix where email address contains a #. I have a email address like this : #test@test.com I want to send email like malix -s "TEST" #test@test.com < SOMEFILE I tried \# but doesn't work. Please let me know how we can achieve this? I am in... (1 Reply)
Discussion started by: jingi1234
1 Replies

8. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies
Login or Register to Ask a Question