Function DatePart(Interval As String,dt As String) As Integer Select Case LCase$(Interval) Case "s"' Seconds DatePart=Val(Right$(dt,2)) Case "m"' Minutes DatePart=Val(Mid$(dt,15,2)) Case "h"' Hours DatePart=Val(Mid$(dt,12,2)) Case "dd" 'Days DatePart=Val(Left$(dt,2)) Case "mm"' calendar Month DatePart=Val(Mid$(dt,4,2)) Case "yyyy"' Year DatePart=Val(Mid$(dt,7,4)) Case Else DatePart=0 End Select End Function