AsifMughal
asked on
Problems with Dates in UK format for a filter
Hello All
I am defining a filter for a recordset which brings back records between two given dates. The code is as follows:
if (!m_strSearchDateTo.IsEmpt y() && !m_strSearchDateFrom.IsEmp ty()) {
if (!pDoc->m_pPatientSet->m_s trFilter.I sEmpty()) {
pDoc->m_pPatientSet->m_str Filter += " AND ";
}
pDoc->m_pPatientSet->m_str Filter += "Fare_DateFrom >= #" + DateFrom + "# AND " + "Fare_DateTo <= #" + DateTo + "#";
}
}
This code only works if the date is in American Format mm/dd/yy and does not work for the date in English format dd/mm/yy. I have checked my machine setting and they are set to the English date system.
I have tried using the format command to convert the English date to the American date so that it can be used by the query, using the following code:
CString Temp1;
Temp1.Format(m_strSearchDa teFrom , "%m/%d/%y");
This has not worked, as the Filter reads the date in the English format instead of the American format. Is anyone aware how to convert a English format date to an American date format? I am using ODBC using the CRecordSet class.
Look forward to your reply.
Best Regards
Asif
I am defining a filter for a recordset which brings back records between two given dates. The code is as follows:
if (!m_strSearchDateTo.IsEmpt
if (!pDoc->m_pPatientSet->m_s
pDoc->m_pPatientSet->m_str
}
pDoc->m_pPatientSet->m_str
}
}
This code only works if the date is in American Format mm/dd/yy and does not work for the date in English format dd/mm/yy. I have checked my machine setting and they are set to the English date system.
I have tried using the format command to convert the English date to the American date so that it can be used by the query, using the following code:
CString Temp1;
Temp1.Format(m_strSearchDa
This has not worked, as the Filter reads the date in the English format instead of the American format. Is anyone aware how to convert a English format date to an American date format? I am using ODBC using the CRecordSet class.
Look forward to your reply.
Best Regards
Asif
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Having said that, the original code will work, it's just confusing the way I wrote it