Reputation: 45
I have a user inputted via a userform.textbox.value. General date that I want to switch to a short date. (Or try to get the time to drop so it reads 00:00). I tried the code
sDate=format(date,(d))
but that returns the current date rather than the variable date without the time. I mainly just want to drop the time so if there is an easier way to do that I would be accepting of the idea.
Upvotes: 0
Views: 3102
Reputation: 8591
Please, see: Format function.
Usage:
'UserForm has a TextBox named TxtDate
Dim myDate As Date, sDate As String
myDate = Me.TxtDate 'DateSerial(2014,12,11)
sDate = Format(myDate, "Short Date")
'or
sDate = Format(myDate, "yyyy/MM/dd")
Upvotes: 1