home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.oracle      Overblown overpriced overengineered SHIT      2,288 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,542 of 2,288   
   Waldhausen to All   
   Re: I must be missing the obvious   
   01 Jul 04 09:55:01   
   
   From: wald_no@spam_dba.kiev.ua   
      
   Hello, Joe,   
      
   near 09:03 30-Jun from joe.powell@lmco.com accepted:   
      
   > We datestamp each record in table X with sysdate. In order to query   
   > all table X records in the previous month including its last second, I   
   > search between the first day of the last and current month. But for   
   > reports, I show the end date of the report as the last second of last   
   > month because humans think "from 1 to 30" not "between 1 and 31". So   
   > what is the standard for these queries?   
      
   There are no "standard" how you can see... The best practicies instead.   
      
   Assume   
      
   CREATE TABLE T1(d1 date, n1 number);   
      
   In order to receive previous month's data I'm using this statement   
      
   SELECT SUM(n1)   
   FROM T1   
   WHERE d1 >= trunc(add_months(sysdate,1),'month')   
   	AND d1 < trunc(sysdate, 'month');   
      
   Doing so you can get the data without thinking about measuring precision   
   (second or fraction of it).   
      
   > I can to_char the datestamp--but that is very slow--and changing the   
   > datestamp's type to varchar2 is not possible nor am I sure desireable.   
      
   cast (if you really using timestamp datatype), to_char makes it possible   
   (not desireable of course).   
      
   > Am I the only one with this question?   
      
   Anyone who makes reports has solved this question, I think.   
      
   --   
   wbr,   
   Wit.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca