Now() function with time trim

前端 未结 6 1036
忘了有多久
忘了有多久 2020-12-16 10:23

So the function =Now()....is there a way I can use this and only get the date, not the time?

or is there just a function for this idea?

6条回答
  •  星月不相逢
    2020-12-16 11:09

    I would prefer to make a function that doesn't work with strings:

    '---------------------------------------------------------------------------------------
    ' Procedure : RemoveTimeFromDate
    ' Author    : berend.nieuwhof
    ' Date      : 15-8-2013
    ' Purpose   : removes the time part of a String and returns the date as a date
    '---------------------------------------------------------------------------------------
    '
    Public Function RemoveTimeFromDate(DateTime As Date) As Date
    
    
        Dim dblNumber As Double
    
        RemoveTimeFromDate = CDate(Floor(CDbl(DateTime)))
    
    End Function
    
    Private Function Floor(ByVal x As Double, Optional ByVal Factor As Double = 1) As Double
        Floor = Int(x / Factor) * Factor
    End Function
    

提交回复
热议问题