DatePart Function Example

The example takes a date and displays which quarter of the year it falls in.  To try this example, draw a text box, a label, and a command button on a new form.  Set the AutoSize property of the Label to True.  Paste this code over the Form_Load procedure, and then press F5 to run the program.

Sub Command1_Click ()
  Label1.Caption = "Quarter: " & DatePart("q", Text1.Text)
End Sub