![]() |
convert date as text to number
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 -- donwb |
convert date as text to number
Hi,
Try: Dim d as date d=DateValue( <date_string ) -- Regards, Sébastien <http://www.ondemandanalysis.com "donbowyer" wrote: 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 -- donwb |
convert date as text to number
datevalue("dd/mm/yy")
"donbowyer" wrote: 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 -- donwb |
convert date as text to number
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 "donbowyer" wrote in message ... 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 -- donwb |
convert date as text to number
Thanks everyone for the responses.
Simply using DateValue did the trick. -- donwb "Rick Rothstein (MVP - VB)" wrote: 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 "donbowyer" wrote in message ... 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 -- donwb |
All times are GMT +1. The time now is 12:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com