Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2012

    Unanswered: Horrible Date Entries

    I don't know a lot about DB2, and I have to query a database to find records within dynamic date parameters. That is not the hard bit: the date entered in the DB is in DDMMYY as an integer.

    So far I have managed to query and create a field for day, month and year, but with the 2-digit year I am finding myself stuck.

    Is there a way to adjust the field value to 19xx or 20xx based on the value od xx? It started in the 90s and we will have moved to a different platform within the next 20 years, so I just want to prefix the value for now. Is it possible to do it within the query? Apologies if this sounds stupid.

  2. #2
    Join Date
    Jun 2003
    Toronto, Canada
    Provided Answers: 1
    I'm sure a CASE expression can help.
      WHEN (date_col - INT(date_col / 100) * 100) between 0 and 12 
      THEN 2000 + (date_col - INT(date_col / 100) * 100) 
      ELSE 1900 + (date_col - INT(date_col / 100) * 100) 
    END as year_value
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Oct 2012
    Perfect, thanks!

Posting Permissions

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