If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Time difference

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-17-11, 05:26
ai_zaviour ai_zaviour is offline
Registered User
 
Join Date: Sep 2011
Posts: 53
Time difference

Hello all

I have a problem when taking time difference..

The table have a TO_TIME and FROM_TIME time columns..

So when a data enters.. I need to check whether this enter data exists in the above columns..

I have tried something like this...

SELECT * FROM PROGRAMME_SCHEDULE_DTL
WHERE SCHEDULE_ID = '87'
AND '00:00:01','07:00:00' NOT BETWEEN TO_TIME AND FROM_TIME

i know this i wrong...

Any one have ideas..

This is the table structure

CREATE TABLE "DB2ADMIN"."PROGRAMME_SCHEDULE_DTL" (
"SCHEDULE_ID" INTEGER NOT NULL,
"SEQUENCE" INTEGER NOT NULL,
"FROM_TIME" TIME,
"TO_TIME" TIME,
"PROGRAMME_ID" INTEGER NOT NULL,
"DESCRIPTION" VARCHAR(500),
"DEFAULT_URL" VARCHAR(150),
"ACTIVE_STATUS" INTEGER NOT NULL DEFAULT 1
)
Reply With Quote
  #2 (permalink)  
Old 09-17-11, 06:13
dbzTHEdinosaur dbzTHEdinosaur is offline
Registered User
 
Join Date: Jun 2007
Location: germany
Posts: 96
you say
Quote:
I need to check whether this enter data exists in the above columns..
yet your sql is looking for a
time LT FROM_TIME OR GT TO_TIME
(yes I know, I reversed your BETWEEN)

instead of negative which will return useless rows
if you are indeed looking to see if the TIME already exists,

why don't you

SELECT 1
FROM PROGRAMME_SCHEDULE_DTL
WHERE
:ENTERED-TIME BETWEEN FROM_TIME AND TO_TIME

SQLCODE = 0 means the time exists
SQLCODE = +100 means time does not exist
which is what you said you wanted.
__________________
Dick Brenholtz, Ami in Deutschland
Reply With Quote
  #3 (permalink)  
Old 09-20-11, 12:07
dbzTHEdinosaur dbzTHEdinosaur is offline
Registered User
 
Join Date: Jun 2007
Location: germany
Posts: 96
in four years i provide a decent answer to a question
and the topic starter does not return.
__________________
Dick Brenholtz, Ami in Deutschland
Reply With Quote
  #4 (permalink)  
Old 09-20-11, 13:09
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Quote:
Originally Posted by dbzTHEdinosaur View Post
in four years i provide a decent answer to a question
and the topic starter does not return.
It happens too often. Every regular here will have this experience.

Don't take it personally.

Thanks for your contribution and keep coming back.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 09-21-11, 01:25
ai_zaviour ai_zaviour is offline
Registered User
 
Join Date: Sep 2011
Posts: 53
Hai
Sorry man...

I was too busy with work and could not log in to the forum for a while..

Thanx for the solution you provided..

It worked..
Reply With Quote
  #6 (permalink)  
Old 09-21-11, 04:49
dbzTHEdinosaur dbzTHEdinosaur is offline
Registered User
 
Join Date: Jun 2007
Location: germany
Posts: 96
Talking

ahhh! the feeling of being appreciated, nothing beats it.
thx ai zaviour.
__________________
Dick Brenholtz, Ami in Deutschland
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On