wood burning stoves 2.0
The moose likes JDBC and Relational Databases and the fly likes datepart error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "datepart error" Watch "datepart error" New topic

datepart error

bubu lina

Joined: Aug 11, 2008
Posts: 28
trying to extract the year from a date database field, i keep on getting sql error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DATEPART (year, '2007-06-01')' at line 1

this is what i am trying..and not succeeding...:

i am sure this is wrong... but i don't know the correct syntax for this.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

"low range", two things:

1) Please check your private messages for an important administrative matter.

2) Please use real words when posting to the forums. Abbreviations such as "err" in place of "error" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

JavaRanch sheriff

[Asking smart questions] [About Bear] [Books by Bear]
Jan Cumps

Joined: Dec 20, 2006
Posts: 2565

Is DATEPART supported by mysql?
I did not find it documented in the reference.
They do have a YEAR() function though.

Regards, Jan

OCUP UML fundamental and ITIL foundation
I agree. Here's the link: http://aspose.com/file-tools
subject: datepart error
It's not a secret anymore!