DatePart Function /text/sbasic/shared/03030130.xhp
DatePart function

DatePart Function

The DatePart function returns a specified part of a date.
DatePart (interval As String, date As Date [, firstDayOfWeek As Integer [, firstWeekOfYear As Integer]]) As Long

Return value:

The extracted part for the given date. interval - A string expression from the following table, specifying the date interval. date - The date from which the result is calculated. Sub example_datepart MsgBox DatePart("ww", #01/02/2005#) ' displays 2 because weeks start on Sunday MsgBox DatePart("ww", #12/31/2005#) ' displays 53 MsgBox DatePart(date:=#2005-12-30#, interval:="q") ' displays 4 End Sub