Dates in one field

G

Guest

I have a field that contains dates in the following format:
1/1/03 - 1/2/03
11/1/03 - 11/2/03

I would like to be able to split the dates but I am unable
to use the "left" function. The space before the dash and
after the dash is consistent but I don't know how to use a
function that will cut off the date based on the space in
the middle. In excel it is easy to do by using the
delimited function.

Does anyone know what I could use for this?

I would really appreciate your help.
 
B

Brian Camire

You might use (say, in a query) an expression like this

CDate(Trim(Left(YourField, InStr(1, YourField, "-") - 1)))

to get the "start" date, and one like this

CDate(Trim(Mid(YourField, InStr(1, YourField, "-") + 1)))

to get the "end" date.
 
G

Guest

It works perfect

Thank you very much.

-----Original Message-----
You might use (say, in a query) an expression like this

CDate(Trim(Left(YourField, InStr(1, YourField, "-") - 1)))

to get the "start" date, and one like this

CDate(Trim(Mid(YourField, InStr(1, YourField, "-") + 1)))

to get the "end" date.




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top