Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2014
    Posts
    5

    Unanswered: Current date comparision using case like clause

    Hi,

    I would like to write a db2 select query which can compare current system time with the Acess time [A_time]

    If Current_time A_time <= 1hr then 1
    If Current_time A_time >=1hr then 2
    If current_time > A_time then 3

    Please help me on this query formation

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Code:
    case 
    when current time > a_time then 3 
    when current time >=  a_Time - 1 hour then 1 
    when current time <= a_time - 1 hour then 2
    end

    Andy

  3. #3
    Join Date
    Aug 2014
    Posts
    5

    need complete db2 select query

    I can write oracle query using case, i am new to db2 and I need complete query for implementing current_date_time using case in db2,

  4. #4
    Join Date
    Aug 2014
    Posts
    5

    need complete db2 select query

    I would really appreciate if anyone can tel me the complete db2 query.

    I know how to write Oracle queries using case, but in db2 i never wrote and I don't see any option like 'SYSDATE' in db2 to get current date_time to do comparison using case,


    Thanks

  5. #5
    Join Date
    Apr 2012
    Posts
    1,034
    Provided Answers: 18
    Get familiar with the on-line documentation, in particular with the special registers CURRENT TIME and CURRENT TIMESTAMP at the link below:
    IBM Knowledge Center

  6. #6
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Though, this aricle is a little old and some functions(to_char, to_date, so on...) are not mentioned,
    it covered concisely almost need to know(about date/time in DB2) for beginners of DB2.
    DB2 Basics: Fun with Dates and Times

Posting Permissions

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