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 > DB2 help in sysdate

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-22-09, 03:20
vivek.vivek vivek.vivek is offline
Registered User
 
Join Date: Jan 2009
Posts: 27
Question DB2 help in sysdate

Please help me to convert the ststement:

select count(Test.Batch_Name) as count1 from Test where Test.Batch_name='BATCH_0001' and sysDate < (select Batch.Batch_End_Date from batch where Batch.Batch_Name='BATCH_0001') and sysDate > (select Batch.Batch_Start_Date from batch where Batch.Batch_Name='BATCH_0001')

Instead of sysdate i used current date. But its showing null result in DB2.
In oracle it is showing count as 15.

Thanks in Advance
Vivek
Reply With Quote
  #2 (permalink)  
Old 01-22-09, 03:38
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
sysDate is in oracle....the alternative for the same in db2 is CURRENT_TIMESTAMP so your sql script will change to
Quote:
SELECT count (Test.Batch_Name) AS count1
FROM Test
WHERE Test.Batch_name = 'BATCH_0001'
AND CURRENT_TIMESTAMP < (SELECT Batch.Batch_End_Date
FROM batch
WHERE Batch.Batch_Name = 'BATCH_0001')
AND CURRENT_TIMESTAMP > (SELECT Batch.Batch_Start_Date
FROM batch
WHERE Batch.Batch_Name = 'BATCH_0001')
also check the data in both systems
__________________
IBM Certified Database Associate, DB2 9 for LUW

Last edited by nick.ncs; 01-22-09 at 03:41.
Reply With Quote
  #3 (permalink)  
Old 01-22-09, 03:38
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
(I will delete.)
Reply With Quote
  #4 (permalink)  
Old 01-22-09, 03:49
vivek.vivek vivek.vivek is offline
Registered User
 
Join Date: Jan 2009
Posts: 27
Ok.Thank You. it is working
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