DB2 query syntax for timestamp datatype

I am new to DB2, and have got my syntax wrong
I am querying a DB2 database ,
With the following  query
   WHERE CLOSED_DATE BETWEEN '2011-12-01' AND '2011-12-14'
I am getting the following eror returned
"The syntax of the string representation of a datetime value is

CLOSED_DATE  is of timestamp datatype
any help appreciated,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try explicitly converting your strings to dates:

   WHERE CLOSED_DATE BETWEEN Date('2011-12-01') AND Date('2011-12-14')

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
blossomparkAuthor Commented:
Hi mbizup...
thanks ...works 100%
Kent OlsenDBACommented:
Hi Blossom,

Note that DB2 doesn't require you convert a string to a date.  That's one of the nicer features of DB2 SQL.  But DB2 also won't try "all" of the known date formats to see if it can match one to your string.  If the date in the string matches the default date type for your database, all is good.

   WHERE CLOSED_DATE BETWEEN '12/01/2011' AND '12/14/2011'

Depending on your default date format, that would probably have worked for you and is a preferred syntax in DB2.

Good Luck,
blossomparkAuthor Commented:
Thanks Kent
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.