DatePart Function Example

This example takes a date and, using the DatePart function, displays the quarter of the year in which it occurs.

Dim TheDate As Date    ' Declare variables.
Dim Msg    
TheDate = InputBox("Enter a date:")
Msg = "Quarter: " & DatePart("q", TheDate)
MsgBox Msg