Search code examples
vb6date-formatting

VB6: How to remove the Time part from Date type


I have a Date variable which contains also the time:

Dim dt As Date
dt = "8/3/2016 7:10:40 AM"

--> remove somehow the time so the result should be:

dt = "8/3/2016"

How to remove the time?


Solution

  • For another Date type variable:

    dt = DateValue(dt)
    

    or

    dt = CDate(Int(dt))
    

    Or for a string:

    strdt = format$(dt, "m/d/yyyy")