Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003

    Unanswered: datediff problems.

    Hi all, I have quite a conundrum, at least for me.

    I need to get the difference in minutes between the current date and a timestamp. However, I have two timestamp fields. The first one could be NULL (TIMESTAMP_1). The second one is never NULL(TIMESTAMP2). What I want to do is say give me the datediff between the max of TIMESTAMP_1 or TIMESTAMP_2 and the current time.

    This is what I tried to select:

    datediff(mi,max(isnull(TIMESTAMP_1,TIMESTAMP_2)),g etdate())

    However, it grabs TIMESTAMP_1 if it's there and if not then it grabs TIMESTAMP_2. How can I tell it to take the max of both?

    This is Sybase ASE 12.5.

    Thanks for any help.

  2. #2
    Join Date
    Oct 2003


    well this is using sql server so code might be a bit different but same concept should be able to be used.

    case when timestamp1 > timestamp2 then DATEDIFF(mi, timestamp1, getdate())
    when timestamp1 < timestamp2 then DATEDIFF(mi, timestamp2, getdate())
    ELSE DATEDIFF(mi, timestamp1, getdate()) END

Posting Permissions

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