SQL for DATE to CHARACTER translation

J

Jennifer Cali

Hello - I'm trying to write a basic query that looks at a person's
ACQUISITION DATE and assignes a character result, showing which company that
person was in prior to the acquisition.

My original case statement reads:

CASE
WHEN JOB.ACQUISITION_DATE = '2008-01-01' THEN 'McDonalds'
WHEN JOB.ACQUISITION_DATE = '2008-02-01' THEN 'Baja Fresh'
ELSE 'Not Part of Acquisition'
END

However, I'm getting an error - think it has something to do with the data
types in that the system is expecting a date and instead I'm passing it a
character. Can anyone help?
 
B

bcap

What you have posted is SQL Server syntax. In Access you would need to do
this:

Switch(JOB.ACQUISITION_DATE = #01/01/2008#, "McDonalds",
JOB.ACQUISITION_DATE = #02/01/2008#, "Baja Fresh")

n.b. when you say "I'm getting an error", it's generally helpful if you
state *what* error.
 
B

bcap

What you have posted is SQL Server syntax. In Access you would need to do
this:

Switch(JOB.ACQUISITION_DATE = #01/01/2008#, "McDonalds",
JOB.ACQUISITION_DATE = #02/01/2008#, "Baja Fresh")

n.b. when you say "I'm getting an error", it's generally helpful if you
state *what* error.
 

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