Currently doing a data migration from a Microsoft Access database to a Microsoft SQL Server database using C#. I am trying to create a query to pull data from the Access database and order by two columns: Surname and Date. The challenge is that Date is a string in the following sample format: 12.01.13 (i.e. YY.MM.DD), which is supposed to represent the 13th of January 2012. So I tried the following query in Access:
SELECT * FROM [Contacts 2012]
order by Surname, CDate(Format(Date, "0000-00-00"));
However, I receive this error:
Data type mismatch in criteria expression
So I figure I am getting close. I tried a few different formats, plus maybe DateValue, but to be honest I can't remember. I have looked at other posts both in and outside of stackoverflow, but to no avail.
Use
Regex.Replacefor date format andRegex.Splitto add 2 digits to year.