Thread

  1. RE: [GENERAL] SELECT Date

    Jackson, DeJuan <djackson@cpsgroup.com> — 1998-10-08T21:37:50Z

    > >I have a table with somedate defined as date.
    > >
    > >I want to select all rows that are from todays date back to 7 days
    > >ago. Or in this case 10-1-1998.
    > 
    > Use the function age() somewhat like this:
    > 
    > select * from sometable 
    > where date_part( 'epoch' , age( 'now', somedate ) ) > 604800
    > 
    > The 'epoch' date part is the total number of seconds between the two
    > dates.
    > For other variations, see:
    > 
    > http://www/postgresql.org/docs/user/functions1574.htm
    > 
    Why don't you just use between:
    select * from sometable
    where somedate between now()::date and (now()::datetime - '@ 7
    days'::timespan)::date;
    	-DEJ
    
    
  2. RE: [GENERAL] SELECT Date

    Andy <alewis@mpsi.net> — 1998-10-12T15:08:56Z

    I tried this but, got the following:
    
    ---------------------------------------
    mytest=> select fagentname from feedback where ftdate between now()::date and
    mytest-> (now()::datetime - '@ 7 days'::timespan)::date;
    ERROR:  function date(timestamp) does not exist
    ---------------------------------------
    
    I have this column identified as type date and not timestamp.
    
    Any suggestions?
    
    
    
    
    On Thu, 8 Oct 1998, Jackson, DeJuan wrote:
    
    >> >I have a table with somedate defined as date.
    >> >
    >> >I want to select all rows that are from todays date back to 7 days
    >> >ago. Or in this case 10-1-1998.
    >> 
    >> Use the function age() somewhat like this:
    >> 
    >> select * from sometable 
    >> where date_part( 'epoch' , age( 'now', somedate ) ) > 604800
    >> 
    >> The 'epoch' date part is the total number of seconds between the two
    >> dates.
    >> For other variations, see:
    >> 
    >> http://www/postgresql.org/docs/user/functions1574.htm
    >> 
    >Why don't you just use between:
    >select * from sometable
    >where somedate between now()::date and (now()::datetime - '@ 7
    >days'::timespan)::date;
    >	-DEJ
    >