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 > help need with converting oracle query to db2 using date manipulation

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-04, 09:11
ronenshi ronenshi is offline
Registered User
 
Join Date: Sep 2004
Posts: 33
help need with converting oracle query to db2 using date manipulation

hi ,
i have a query that manipulate date column in oracle
that needs to be converted to db2.

the oracle query:
select TRUNC(emeh_date_time - -7/24) + -7/24
from <table>

whats the db2 version??

10x
Reply With Quote
  #2 (permalink)  
Old 10-28-04, 09:26
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by ronenshi
hi ,
i have a query that manipulate date column in oracle
that needs to be converted to db2.

the oracle query:
select TRUNC(emeh_date_time - -7/24) + -7/24
from <table>

whats the db2 version??

10x
What does it do in Oracle?
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #3 (permalink)  
Old 10-28-04, 10:11
ronenshi ronenshi is offline
Registered User
 
Join Date: Sep 2004
Posts: 33
the trunc function in oracle truncate the time from the datetime .
and in the statement context: its truncating the emeh_date_time and adds hours then remove hours
Reply With Quote
  #4 (permalink)  
Old 10-28-04, 10:17
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by ronenshi
the trunc function in oracle truncate the time from the datetime .
and in the statement context: its truncating the emeh_date_time and adds hours then remove hours
A little confused as to why you'd want to add then remove hours? But anyway you're probably looking for the TIME function combined with the adding of a duration, ie:

TIME(CURRENT TIMESTAMP) + 3 hours

jono
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #5 (permalink)  
Old 10-28-04, 10:22
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Ahh, I think you mean that the time is truncated, not return, I think I misread.

DATE(blah) will do the trick on that one then. You can still use the duration.
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #6 (permalink)  
Old 10-28-04, 10:44
ronenshi ronenshi is offline
Registered User
 
Join Date: Sep 2004
Posts: 33
yes i need to had time to a date function
like select date(<col type timestamp>) + 3 hours (3 is a parameter)

can u specify the full select cause i tried it and it didnt work
10x
Reply With Quote
  #7 (permalink)  
Old 10-28-04, 10:49
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by ronenshi
yes i need to had time to a date function
like select date(<col type timestamp>) + 3 hours (3 is a parameter)

can u specify the full select cause i tried it and it didnt work
10x
I'm still not 100% clear on what you're trying to do.

DATE(timestamp) will return the date portion.

You can't add hours to a DATE though, only days, months, etc. But you can add hours to the timestamp before you apply it.

So
DATE(CURRENT TIMESTAMP + 3 HOURS)
or
DATE(CURRENT TIMESTAMP) + 1 DAY

should both work... replacing CURRENT TIMESTAMP with what I presume is your TIMESTAMP column.
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #8 (permalink)  
Old 10-28-04, 11:07
ronenshi ronenshi is offline
Registered User
 
Join Date: Sep 2004
Posts: 33
10x thats what i was looking 4 :-)
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