Results 1 to 2 of 2
  1. #1
    Join Date
    May 2003
    Posts
    1

    Unanswered: question about YEAR() function

    Hi,

    When I use the next statement I don't have any problems :

    select c.bb_nr, d.bbl_nr, a.lev_nr, a.naam1, f.land_nm_e, b.naam, b.e_mail, d.prod_cd, d.oms, e.kwan_hvh, d.lev_dat
    from DB2.VACPLEVERANCIER a, DB2.LEV_KONTAKTEN b,
    DB2.BBH c, DB2.BBL d,
    DB2.ONTVANGST e, DB2.LAND f
    where (a.lev_nr = b.lev_nr
    and a.lev_nr = c.lev_best_nr)
    and (c.bb_nr = d.bb_nr
    and e.bb_nr = d.bb_nr)
    and e.bbl_nr = d.bbl_nr

    But when I want to convert the d.lev_dat column to char it doesn'4t work. Currently I get something like '19/jan/2001" in this column. I want to get only 2001 ...
    I also tried to use YEAR(d.lev_dat) but then I get the following error :
    ORA-00904 : invalid column-name

    How can the column name be invalid when it works without the YEAR() ?
    Anyone can help me ?

  2. #2
    Join Date
    Mar 2003
    Posts
    33

    Re: question about YEAR() function

    Year -function returns the year portion of a date, a timestamp, or a duration. So, you should be able to use it like year('mm/dd/yyyy') or year('dd.mm.yyyy') but NOT like
    year('19/jan/2001').





    Originally posted by BenB
    Hi,

    When I use the next statement I don't have any problems :

    select c.bb_nr, d.bbl_nr, a.lev_nr, a.naam1, f.land_nm_e, b.naam, b.e_mail, d.prod_cd, d.oms, e.kwan_hvh, d.lev_dat
    from DB2.VACPLEVERANCIER a, DB2.LEV_KONTAKTEN b,
    DB2.BBH c, DB2.BBL d,
    DB2.ONTVANGST e, DB2.LAND f
    where (a.lev_nr = b.lev_nr
    and a.lev_nr = c.lev_best_nr)
    and (c.bb_nr = d.bb_nr
    and e.bb_nr = d.bb_nr)
    and e.bbl_nr = d.bbl_nr

    But when I want to convert the d.lev_dat column to char it doesn'4t work. Currently I get something like '19/jan/2001" in this column. I want to get only 2001 ...
    I also tried to use YEAR(d.lev_dat) but then I get the following error :
    ORA-00904 : invalid column-name

    How can the column name be invalid when it works without the YEAR() ?
    Anyone can help me ?
    -r-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •