Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2009
    Posts
    1

    Question Unanswered: date DB2 and ASP

    I'm using a textbox with this string value in ASP code

    <TD><b>DATE1:</b></TD><TD><INPUT TYPE="text" NAME="FDESDE" value="01/01/2000" SIZE=10 MAXLENGHT=10></TD>

    SELECTSQL = "SELECT * FROM tabla1 INNER JOIN tabla2 ON tabla1.cod = tabla2.cod where campo2='002' campo3= DATE('" & FDESDE & "')"

    and it doesn't work!

    but it works with this command
    SELECTSQL = "SELECT * FROM tabla1 INNER JOIN tabla2 ON tabla1.cod = tabla2.cod where campo2='002' campo3=(SELECT CURRENT DATE AS FEC FROM SYSIBM.SYSDUMMY1)"

    I'm using db2 6 and the field CAMPO3 in my table1 have this value from control center DB2
    campo3
    2009-01-20
    2009-02-15
    2009-03-21
    2009-04-01
    2009-05-07
    2009-06-30

    Please how to convert string value of my variable to db2 date format in ASP.
    Thanks

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by peterflores

    Please how to convert string value of my variable to db2 date format in ASP.
    This isn't a "DB2 date format", it is an ISO date format. If you re-phrase your question like that, I suspect you will have more chances to have it answered in the ASP forum.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    May 2009
    Posts
    258
    DB2 is most likely expecting the date to be in the form of '2000-01-01'. You can check the format it wants by using the following query:
    Code:
    SELECT CHAR(CURRENT_DATE) FROM SYSIBM.SYSDUMMY1
    Regards,

    Ax

  4. #4
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    DB2 can recognize some date formats. For example:
    Code:
    ------------------------------ Commands Entered ------------------------------
    SELECT str
         , DATE(str) AS str_to_date
      FROM (VALUES
            '2009-08-17', '08/17/2009', '17.08.2009') s(str)
    ;
    ------------------------------------------------------------------------------
    
    STR        STR_TO_DATE
    ---------- -----------
    2009-08-17 2009-08-17 
    08/17/2009 2009-08-17 
    17.08.2009 2009-08-17 
    
      3 record(s) selected.
    And, DATE data type can be converted to some string representations. For example:
    Code:
    ------------------------------ Commands Entered ------------------------------
    SELECT date
         , CHAR(date, ISO) date_iso
         , CHAR(date, USA) date_usa
         , CHAR(date, EUR) date_eur
      FROM (VALUES current_date) s(date)
    ;
    ------------------------------------------------------------------------------
    
    DATE       DATE_ISO   DATE_USA   DATE_EUR  
    ---------- ---------- ---------- ----------
    2009-08-12 2009-08-12 08/12/2009 12.08.2009
    
      1 record(s) selected.

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Are you seriously still using DB2 V6?!?

    Please provide the exact error message that you get.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

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