Marv said:
Sorry, I did not correctly explain properly what I was trying to do.
I have a query that uses data from a linked table that I do not control. The
query allows the user to select a date range for the data to be displayed.
The data field in the in the old table was text and looked like a date
mm/dd/yyyy. I used the Cdate() to convert it to a date field and then the
user could enter the start date mm/dd/yyyy and the end date mm/dd/yyyy.
The table has been changed and now the text in the date field looks like
this mm/yy. The user will now enter a start date mm/yy and an end date
mm/yy.
The Cdate() function does not seem to work on mm/yy.
CDate does what it says it will do. Unfortunely, you want
it to do something else. A string of the form a/b will be
interpreted as mm/dd and CDate will automatically supply the
current year.
I think you could have avoided all this if you just leave
the table field as you originally converted it. It's up to
the query to manipulate it to meet your criteria's needs.
It's always possible to not use unneeded information, but it
is impossible to make up reliable data from partial
information. Eg. You could easily set the format for the
date field to mm/yy, but you can no longer determine the day
of the month after discarding that information.
For example, if the table's date field has arbitrary dates,
then the query can use a calculated field with an expression
like:
MyDate: Format(datefield, "yyyymm") Between
Format(CDate("1/" & [Start Date], "yyyymm") And
Format(CDate("1/" & [End Date], "yyyymm")
with a criteria of True
As indicated by the various replies to your original
question, there are many variations that can be used for
this purpose.
You can get what you asked using the above by using
Format("1/" & funkytextdatefield, "yyyymm")
but it sure is going the long way around the issue.