I need this: 38842.8287152778 to be converted into 05052006_075321PM. This is the date for May 5th 2006 @ 7:53:21 pm in VBA. How do i get there from 38842.8287152778?
Serial date conversion to semi string data.
-
-
-
Re: Serial date conversion to semi string data.
You can use custom format. Select the whole column. Right click go to format cells then number then select custom and type this in the custom box.
[COLOR="Navy"]mmddyyyy"_"hhmmss AM/PM[/COLOR]
-
Re: Serial date conversion to semi string data.
I need it to happen inside VBA.
-
Re: Serial date conversion to semi string data.
Can it be recorded a regular macro?
-
-
Re: Serial date conversion to semi string data.
You can try this
Code
Display MoreFunction ConvertTime(ByRef strValue As String) As String If strValue <> "" Then ConvertTime = Format$(strValue, "mmddyyyy_hhmmssAM/PM") End If End Function Sub Test() Dim str As String str = ConvertTime("38842.8287152778") Debug.Print str End Sub
you can pass in a cell value and it should do what you want
-
Re: Serial date conversion to semi string data.
Thanks for the goods fellas...
-
Re: Serial date conversion to semi string data.
Cdate works easy enough. I had been looking for an easy way to get that done. I am new to VBA, so I haven't seen that debug.print <string> command before. That is pretty cool.
-
Re: Serial date conversion to semi string data.
It is probably overkill, but if you wanted to use a function with Insomniacs suggestion of CDate() it is simple enough to change my original one;
-
Re: Serial date conversion to semi string data.
Thanks for all the suggestions. You guys helped a lot.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!