date between problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • coolminded
    New Member
    • Mar 2007
    • 137

    date between problem

    hi all,
    i have created a function. i got the problem. it doesn't show the out put if i put between condition. but it works perfectly when used only ">" condition only in the date
    ie
    create or repl...
    ...
    ..
    to_char('||quot e_ident(date_ty pe)||',''yyyy-mm-dd'')
    > '||from_date ;

    ....
    ....
    ....

    the function is

    CREATE OR REPLACE FUNCTION fnGetUser(date, date, text )
    RETURNS SETOF user_report AS
    $BODY$
    declare
    from_date alias for $1;
    to_date alias for $2;
    date_type alias for $3;

    query refcursor;
    r user_report%row type;
    begin
    open query for execute 'SELECT
    id_no,
    entry_dt,
    name,
    tel
    from tbl_user
    where to_char('||quot e_ident(date_ty pe)||',''yyyy-mm-dd'')
    between '||from_date||' and ''||to_date;
    loop
    fetch query into r;
    if not found then return ;
    else
    return next r;
    end if;
    end loop;
    close query;
    return;
    end;
    $BODY$
    LANGUAGE 'plpgsql' VOLATILE;

    also when i used "<"(lesser than) condition, it doesn't show the result as well.
    so i want to know how to use the "between" condition to check the date.

    TIA
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    What is the value of datestyle setting?
    Code:
    show datestyle;
    what are the values in the table in columns from_date i to_date?

    Comment

    Working...