Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Change
CDate(".5") to CDate(Val(".5")) or even don't use CDate at all, only use Val() Reason is CDate assumes user the string is already 'like' a time, rather than an ordinary number Regards, Peter T wrote in message ... I am having problems with converting text to date using the cdate function When I convert .5 into a format of HH:MM AM/PM it becomes 12:00 PM which makes sense because noon is half of a day When I convert 0.5 into a format of HH:MM AM/PM it becomes 12:05 AM which doesn't make sense When I convert 0.50 into a format of HH:MM AM/PM it becomes 12:50 AM which also doesn't make sense When I convert 0.500 into a format of HH:MM AM/PM it becomes 12:00 PM Below is a msgbox that demonstrates this. What is happening? Sub test1() MsgBox "The string "".5"" converts to " & Format(CDate(".5"), "MMM dd yyyy HH:MM AM/PM") _ & vbLf & "The string ""0.5"" converts to " & Format(CDate("0.5"), "MMM dd yyyy HH:MM AM/PM") _ & vbLf & "The string ""0.50"" converts to " & Format(CDate("0.50"), "MMM dd yyyy HH:MM AM/PM") _ & vbLf & "The string ""0.500"" converts to " & Format(CDate("0.500"), "MMM dd yyyy HH:MM AM/PM") End Sub Thanks for any help Merlyn |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
make signed over-punch conversion work in a macro | Excel Programming | |||
Converting a date from nonsense to sense | Excel Discussion (Misc queries) | |||
Does this make sense? | Excel Programming |