Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Posts
    27

    Question Unanswered: 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

  2. #2
    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
    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
    Last edited by nick.ncs; 01-22-09 at 04:41.
    IBM Certified Database Associate, DB2 9 for LUW

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    (I will delete.)

  4. #4
    Join Date
    Jan 2009
    Posts
    27
    Ok.Thank You. it is working

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •