bhardin Posted June 4, 2008 Share Posted June 4, 2008 How do you typecast a date to a string?I am trying to search an AS400 database through the ODBC connection for a date of 01/01/0001.If I use this SQL statement it translates the date to 01/01/2001 SELECT * FROM BLPSO WHERE BLPSO.SORTDT = #01/01/0001# If I try to use the following SQL Statement it throws a type mismatch error SELECT * FROM BLPSO WHERE BLPSO.SORTDT = '01/01/0001' Any ideas?? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 4, 2008 Share Posted June 4, 2008 An AS/400 server uses a DB2 database. You should be able to find references for that online.http://www.google.com/search?client=opera&...-8&oe=utf-8 Link to comment Share on other sites More sharing options...
aspnetguy Posted June 4, 2008 Share Posted June 4, 2008 have you tried SELECT * FROM BLPSO WHERE BLPSO.SORTDT = CAST('01/01/0001' AS DATETIME) Link to comment Share on other sites More sharing options...
bhardin Posted June 4, 2008 Author Share Posted June 4, 2008 ASPNetGuy:That still didn't work. I don't really understand what is happening here but...If I Open Excel and use the SQL Editor I can use this StatementSELECT * FROM BLPSO WHERE BLPSO.SORTDT = '01/01/0001'if I use the wizard then it returns stuff that has a date 01/01/2001If I use DAO in VB6 it also returns stuff that has a date 01/01/2001JustSomeGuy:I couldn't find what I was looking for in that search or any other searchthat I did. I even tried using stuff like "date returned as 01/01/2001 instead of 01/01/0001"Not sure if I'm just missing what I need to see or what.Still don't have it working. Link to comment Share on other sites More sharing options...
bhardin Posted June 4, 2008 Author Share Posted June 4, 2008 Ok i changed the SQL to Select * FROM BLPSO WHERE BLPSO.SORTDT < #01/01/1930#It does what I want it to do but I would still like to understand the issue better. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.