CRecordset-related question
-
Hi all, I am using a Crecordset class to retrieve rows from an access database table. I am constructing the WHERE statement at runtime and pass it to CRecordset using m_strFilter. The problem is the following: I need to query a date field in the database (rem_date) based on a date provided by the user (m_date). I am using the following code (v_filter is the where statement): v_filter+="(rem_date="; v_filter+="{d'"; v_filter+=m_date.Format("%Y-%m-%d");:confused: v_filter+="'}"; v_filter+=" )"; The problem is that the above statement returns TRUE only when both the date and the (hidden) time is the same. I only need to compare the date portion. Do you know how can I do this? I thank yuo in advance, Christos P.
-
Hi all, I am using a Crecordset class to retrieve rows from an access database table. I am constructing the WHERE statement at runtime and pass it to CRecordset using m_strFilter. The problem is the following: I need to query a date field in the database (rem_date) based on a date provided by the user (m_date). I am using the following code (v_filter is the where statement): v_filter+="(rem_date="; v_filter+="{d'"; v_filter+=m_date.Format("%Y-%m-%d");:confused: v_filter+="'}"; v_filter+=" )"; The problem is that the above statement returns TRUE only when both the date and the (hidden) time is the same. I only need to compare the date portion. Do you know how can I do this? I thank yuo in advance, Christos P.
Do not exactly remember the function that will get you parts of the date in Access but you need to do something like: Where DatePart( date_field, "mm-dd-yy") = DatePart( userDate, "mm-dd-yy" ) Try writing the query in Access it self first. Once you have it working you can can move it to your code by replacing the UserDate with the appropriate variable in your code.
-
Do not exactly remember the function that will get you parts of the date in Access but you need to do something like: Where DatePart( date_field, "mm-dd-yy") = DatePart( userDate, "mm-dd-yy" ) Try writing the query in Access it self first. Once you have it working you can can move it to your code by replacing the UserDate with the appropriate variable in your code.
Dear Ranjan BANERJI, I would like to thank you for your reply but I feel that I have to exemplify my problem a bit more: I am able to extract the date portion from the user-supplied date but I am not able to do the same for the date retrieved from the database. What I need is the name of the SQL function that does this. Thank you for your time, Christos P.:)