DatePart
Public Function DatePart(ByVal Interval As String, ByVal InputDate As Date, Optional ByVal FirstDayOfWeek As Long = 0, Optional ByVal FirstWeekOfYear As Long = 0) As Long
Gets an part from a date.
- Interval: The interval (part-type) to get. Use one of: 'yyyy': year, 'q': quarter, 'm': month, 'y': day of year, 'd': day, 'w': weekday, 'ww': week of year, 'h': hour, 'n': minute, 's': second
- InputDate: The date to get the part from.
- FirstDayOfWeek: The first day of the week (only for 'ww'). Use one of: 0:vbUseSystemDayOfWeek (Effectively Sunday), 1:vbSunday, 2:vbMonday, 3:vbTuesday, 4:vbWednesday, 5:vbThursday, 6:vbFriday, 7:vbSaturday
- FirstWeekOfYear: The first week of the year (only for 'ww'). Use one of: 0:vbUseSystem (Effectively vbFirstFourDays), 1:vbFirstJan1, 2:vbFirstFourDays, 3:vbFirstFullWeek
SendDebug $"The current week is {DatePart("ww", Date, vbMonday, vbFirstFourDates)} and we are in quarter {DatePart("q", Date)}"
See also: