[MonetDB-users] Problem with YEAR, MONTH, DAY functions

Hello, sorry to ask again but i have problem with YEAR, MONTH and DAY functions. According to the references YEAR for example can take as argument a date or a timestamp or a month_interval value. So if i run the query: sql> select year(current_timestamp); or sql> select year( '2002-03-21') it should return 2011 and 2002. Instead of this, i take: *syntax error,unexpected YEAR in: "select year". *What am i doing wrong? Thank you very much in advance

Hi, YEAR is also a keyworkd in SQL. To indicate that you want to use the function (identifier) YEAR, you need to wrap it in double quotes, e.g., sql>select year( '2002-03-21'); syntax error, unexpected YEAR in: "select year" sql>select "year"( '2002-03-21'); +-------------------+ | year_single_value | +===================+ | 2002 | +-------------------+ 1 tuple (1.735ms) Stefan On Thu, Oct 20, 2011 at 01:52:25AM +0300, Roula Avg wrote:
Hello, sorry to ask again but i have problem with YEAR, MONTH and DAY functions. According to the references YEAR for example can take as argument a date or a timestamp or a month_interval value. So if i run the query: sql> select year(current_timestamp); or sql> select year( '2002-03-21') it should return 2011 and 2002. Instead of this, i take: *syntax error,unexpected YEAR in: "select year". *What am i doing wrong?
Thank you very much in advance
------------------------------------------------------------------------------ The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Ciosco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- | Stefan.Manegold @ CWI.nl | DB Architectures (INS1) | | http://CWI.nl/~manegold/ | Science Park 123 (L321) | | Tel.: +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |

On 20-10-2011 08:21:27 +0200, Stefan Manegold wrote:
Hi,
YEAR is also a keyworkd in SQL. To indicate that you want to use the function (identifier) YEAR, you need to wrap it in double quotes, e.g.,
sql>select year( '2002-03-21'); syntax error, unexpected YEAR in: "select year" sql>select "year"( '2002-03-21'); +-------------------+ | year_single_value | +===================+ | 2002 | +-------------------+ 1 tuple (1.735ms)
Alternative is using the EXTRACT function, which makes it a bit more verbose: sql>select extract(year from now()); +-------------------+ | current_timestamp | +===================+ | 2011 | +-------------------+ 1 tuple (11.830ms) sql>select extract(year from '2002-03-21'); +-------------------+ | year_single_value | +===================+ | 2002 | +-------------------+ 1 tuple (0.725ms)
participants (3)
-
Fabian Groffen
-
Roula Avg
-
Stefan Manegold