Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL query not to SELECT something for a period of time

Posted on 2004-08-16
13
Medium Priority
?
511 Views
Last Modified: 2006-11-17
I've an sql query which SELECTs certain fields from a table if the (sysdate - upd_dt) * 1440 > 10
basically, this query is a perl script which gets executed every 5 mins
Now, I need to modify the query so that it doesn't selects anything if the system time is between 0000 and 0115

I dont want to decrease the frequency of the perl script as it does some other stuffs.

Is there any way to perform this?

rgds
prasen
0
Comment
Question by:prasen120998
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
13 Comments
 

Author Comment

by:prasen120998
ID: 11815672
I'm using Oracle database
0
 
LVL 17

Accepted Solution

by:
BillAn1 earned 252 total points
ID: 11815718
You could try something like this :
SELECT * FROM MYTABLE
WHERE (sysdate - upd_dt) * 1440 > 10
AND TO_CHAR('HHMI', sysdate) < '0115'
0
 
LVL 8

Assisted Solution

by:annamalai77
annamalai77 earned 248 total points
ID: 11817804
hi

SELECT *
FROM MYTABLE
WHERE (sysdate - upd_dt) * 1440 > 10
AND to_number(TO_CHAR(sysdate, 'HHMI')) between 0000 and  0115

regards
annamalai
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 11817965
BillAb1 and annamalai77 are on the good way, so give points to them.
But they should read more carefully, because the question is in the negative way, thus add a NOT to the condition:

SELECT *
FROM MYTABLE
WHERE (sysdate - upd_dt) * 1440 > 10
AND NOT TO_CHAR(sysdate, 'HHMI') between '0000' and '0115'

respectively:
ELECT * FROM MYTABLE
WHERE (sysdate - upd_dt) * 1440 > 10
AND TO_CHAR('HHMI', sysdate) > '0115'

Cheers
0
 
LVL 8

Expert Comment

by:annamalai77
ID: 11817981
hi the correct query

a minor correction as said by angel

SELECT *
FROM MYTABLE
WHERE (sysdate - upd_dt) * 1440 > 10
AND to_number(TO_CHAR(sysdate, 'HHMI')) not between 0000 and  0115

regards
annamalai

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 11818027
Hi annamalai77,
may you tell us why you use to_number?
0
 
LVL 8

Expert Comment

by:annamalai77
ID: 11818039
hi angel

just to convert the character data to numeric data thats all. even without to_number the query will work but to avoid any problems which might arise i have used to_number.

regards
annamalai
0
 

Author Comment

by:prasen120998
ID: 11825921
Thanks for the suggestions ---
do I need to change the below
to_number(TO_CHAR(sysdate, 'HHMI'))

to
to_number(TO_CHAR(sysdate, 'HH24MI'))
in order to get the 24 hrs clock?
0
 
LVL 8

Expert Comment

by:annamalai77
ID: 11827355
hi

yes u can use if u want to convert it into a 24hr clock.

regards
annamalai
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 12190166
As I pointed out previously:
>>BillAb1 and annamalai77 are on the good way, so give points to them.
CHeers
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question