M
merlynknight
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
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