Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Apr 2005
    Location
    Ireland
    Posts
    122
    Thanks
    4
    Thanked 0 Times in 0 Posts

    [ oracle ]find part of date

    I nedd to check the year part of date in following format:

    DD-MMM-YYYY

    I have

    Code:
    $year_query = "2006";
    
    qq(SELECT epr_code,
                   epr_name,
                   epr_from,       
                   epr_type
        FROM t_mou_eco_product
        WHERE epr_from LIKE '$year_query\_%' ESCAPE '\'
        AND epr_active = 1
        ORDER BY epr_code);
    This isnt working. Can someone please help?

    Thanks in advance
    Last edited by guelphdad; 08-20-2006 at 01:44 AM.

  • #2
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this.
    Code:
    qq(SELECT epr_code,
                   epr_name,
                   epr_from,       
                   epr_type
        FROM t_mou_eco_product
        WHERE YEAR(epr_from) = '$year_query'
        AND epr_active = 1
        ORDER BY epr_code);

  • #3
    Regular Coder
    Join Date
    Apr 2005
    Location
    Ireland
    Posts
    122
    Thanks
    4
    Thanked 0 Times in 0 Posts
    That year function dosnt seem to be working
    Enetering this in oracle manually

    Code:
    SELECT * FROM t_mou_eco_product
    WHERE YEAR(EPR_FROM) = "2006";
    I get oracle error:

    ORA-00904: "2006": invalid identifier
    Last edited by tom123; 08-15-2006 at 03:18 PM.

  • #4
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    SELECT * FROM t_mou_eco_product
    WHERE to_char(EPR_FROM, 'YYYY') = '2006';

  • #5
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Extract the "YEAR" from the date Column in Oracle

    Please use the followg query to resolve the mentioned error:

    SELECT * FROM <Table_Name>
    WHERE EXTRACT(YEAR FROM TO_DATE(TRUNC(Column_Name), 'DD-MON-RR')) = '2010';

    It is working fine


  •  

    Posting Permissions

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