Converting Short date to a string

T

TimH

I am attempting to convert a Short date entry to a string "00000000-"
Have tried many variations of the following without success:

Public Sub Build_VisitDate()

Dim strTmp As String
Dim dtVisitDate As Date
Dim Build_VisitDate As String

strTmp = InputBox("Enter Visit Date", "Visit Date")
dtVisitDate = Format(CLng(dtVisitDate), "00000000-")


Debug.Print dtVisitDate

End Sub

all I get is either 12:00:00
or
mm/dd/yyyy
not the desired "eight digit string and -"
 
J

John Spencer

If isDate(strTmp) then
dtVisitDate = DateValue(strTemp)
strTemp = Format(dtVisitDate,"yyyymmdd")
End if

You cannot assign a string to dtVisitDate and when you use Format you are
creating a string.
--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
T

TimH

Thank you very much John Spencer! it worked once i edited the

Debug.print strTmp

in the original it still gave me 12:00:00

once again thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top