Solved

SQL query not to SELECT something for a period of time

Posted on 2004-08-16
13
470 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
  • 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 63 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 62 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
 
LVL 142

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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 142

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 142

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now