If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > date DB2 and ASP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-11-09, 11:12
peterflores peterflores is offline
Registered User
 
Join Date: Aug 2009
Posts: 1
Question 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
Reply With Quote
  #2 (permalink)  
Old 08-11-09, 12:19
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
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.
Reply With Quote
  #3 (permalink)  
Old 08-11-09, 13:48
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
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
Reply With Quote
  #4 (permalink)  
Old 08-11-09, 15:23
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
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.
Reply With Quote
  #5 (permalink)  
Old 08-11-09, 17:50
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On