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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top