convert date as text to number

  • Thread starter Thread starter donbowyer
  • Start date Start date
D

donbowyer

I want to subtract one date from another to obtain days between.
The format of the dates is dd/mm/yy
This works fine if both dates are <<numbers>>.
However, one date comes from a UserForm TextBox and is <<Text>>.
I have used successfully the "PasteMultiply" by 1 trick to convert text that
looks like a NUMBER to a true number,
BUT it doesn't seem to work with text that looks like a DATE.
Help please
 
You can use the DateValue function as shown in the other responses or you
can just return the value from the TextBox wrapped in the CDate function...

ReturnValue = CDate(TextBox1.Text)

However, since you are taking your input as a typed in String value, you may
want to test it with the IsDate function (for either the CDate or DateValue
method of conversion) first to make sure you really have a date-shape String
value.

Rick
 
Back
Top