Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    2

    Unanswered: Date manipulation in sql

    i am using sybase 11.9.2.

    I have the following say scenario.....say i have the following rows in a table
    BgnDt EndDt Name LastUpdateDt
    Row 1 19920101 19940105 Sam 19900909

    Row 2 19920101 19940105 Dan 19990909

    Row 3 19940102 19940109 Sam 20000909

    Row 4 19940105 19940109 Sam 20040101

    No if i run the query based on name(Sam) and TimePeriod (StartDate = 19920101 , EndDate = 19959191)
    I would need the results like this -

    BgnDt EndDt Name LastUpdateDt
    19940105 19940109 Sam 20040101
    19940102 19940104 Sam 20000909
    19920101 19940101 Sam 19900909

    As you can see.....the higher LastUpdateDt got preference over the lower LastUpdateDt. And the BgnDt and EndDt were modified to ovoid overlaps.

    Please help

  2. #2
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    524
    Code:
    SELECT BgnDt, EndDt, Name, LastUpdateDt
    FROM ...
    WHERE Name = "Sam"
    ORDER BY LastUpdateDt DESC

  3. #3
    Join Date
    Feb 2004
    Posts
    2

    Please read it carefully

    I think you missed the logic , i am also breaking down the start and end dates.

Posting Permissions

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