Solved

SQL query not to SELECT something for a period of time

Posted on 2004-08-16
13
501 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 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

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…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
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…

734 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