Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String to date value

Status
Not open for further replies.

Peterfb

Programmer
Jul 13, 2009
1
PE
Hi, i have this query in ASP code and it's works ok

SELECTSQL = "SELECT * FROM M_DOCCLI where cdg_tdoc='002' and cdg_tmov<>'998' and fec_docu=(SELECT CURRENT DATE AS FEC FROM SYSIBM.SYSDUMMY1)"

but the problem is when i try to use a variable
I have a textbox with string value '20/03/2008' and this string value is assigned to FDESDE and it doesn't work

SELECTSQL = "SELECT * FROM M_DOCCLI where cdg_tdoc='002' and cdg_tmov<>'998' and fec_docu>= '"& FDESDE &"'"

How convert string value FDESDE to date with format dd/MM/yyyy?

Im working with IBM DB2 v6.0 and when i execute "values current date" command i get this expresion 10/07/2009

Thanks a lot


 
Peterfb,
I think that this is more of an issue with the ASP language rather than DB2, as the troulbe that you appear to be having is assigning the SELECTSQL variable with the correct value, but I may have misunderstood.

What error is being returned? And when are you seeing this error?

Marc
 
Peterfb,
Having thought about this a little more, it could also be that DB2 is not recognising the variable as a date format. You said that when you execute values current date, it comes back with the format dd/mm/yyyy, but that may (or may not) be ASP interpreting it.

Try CCYY-MM-DD or if that doesn't work, try putting the word DATE around it so that your code reads:
Code:
SELECTSQL = "SELECT * FROM M_DOCCLI where cdg_tdoc='002' and cdg_tmov<>'998' and fec_docu>= DATE('" & FDESDE & "')"

Let us know how you get on - hope this helps.

Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top