convert date to quarter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I simply need to provide a fiscal quarter value to a date by month. I've
tried doing this by calling a function within a query and by programming an
event procedure within the form, but can't get the syntax right. Here's one
of my tries
Private Sub Form_Load()
If Format(Me.[DateLastYr], "mmm") Like "Jan" Then
Me.QUART99.Value = 3
End If

End Sub

The error is get shows the syntax in the If line is wrong. I've tried single
quotes, no quotes, etc.
Thanks for your help
 
Use the DatePart() function, e.g.:
DatePart("q", [DateLastYr])

Unless Quart99 is an unbound control, it probably is not a good idea to
change its value in Form_Load.
 
Thanks again, Allen. Knew I could count on you!

Allen Browne said:
Use the DatePart() function, e.g.:
DatePart("q", [DateLastYr])

Unless Quart99 is an unbound control, it probably is not a good idea to
change its value in Form_Load.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

okschlaps said:
I simply need to provide a fiscal quarter value to a date by month. I've
tried doing this by calling a function within a query and by programming
an
event procedure within the form, but can't get the syntax right. Here's
one
of my tries
Private Sub Form_Load()
If Format(Me.[DateLastYr], "mmm") Like "Jan" Then
Me.QUART99.Value = 3
End If

End Sub

The error is get shows the syntax in the If line is wrong. I've tried
single
quotes, no quotes, etc.
Thanks for your help
 
Back
Top