Getting the month part of a date

P

Phil Burns

This should be simple, but I'm stuck and need help.
Placing orders on a database, the date of order creation
is automatically added - in dd/mm/yyyy format. Users can
use this as a select criteria to produce despatch notes,
receipts etc. That all works fine.
We want to add to the despatch note a variable message,
depending on the month eg for all orders received in
January, the message would be "Happy New Year" etc.
I'm starting from having a two column table - months and
messages - separate from everything else, so it can be
managed through a form. How can I get my query to retrieve
the appropriate message from the table?
I expect it will be something like

SELECT Orders.OrderDate, Months.message, Orders.OrderDate
FROM Orders INNER JOIN Months ON Orders.OrderDate =
datepart mm

??
Can anyone help me get the right select statement pls?
 
G

Guido

You might want to try:

SELECT Orders.OrderDate, Months.message, Orders.OrderDate
FROM Orders INNER JOIN Months ON Month(Orders.OrderDate) =
Months.Month

HTH
 

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

Top