Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Convert text date to general number | Excel Discussion (Misc queries) | |||
convert text-format number to number in excel 2000%3f | Excel Discussion (Misc queries) | |||
How do I convert a number formated as a date to text in Excel? | Excel Discussion (Misc queries) | |||
Convert data type of cells to Text,Number,Date and Time | Excel Worksheet Functions | |||
Convert data of cells to any type: Number, Date&Time, Text | Excel Discussion (Misc queries) |