Re: counting days in a query

From: Bjorn Abelli (DoNotSpam.bjorn_abelli_at_hotmail.com)
Date: 12/26/03

  • Next message: Sampsa Sohlman: "Re: JDBC/ODBC user issues accessing SQL Server 2000 database"
    Date: Fri, 26 Dec 2003 22:00:04 +0100
    
    

    "Ike" wrote...
    > How can I make a query such that in the "WHERE" part
    > of my clause, I want to put something to the effect
    > that, say, X days have elapsed since a given date.

    This is not a Java-related question, and you should try to ask such
    questions in a database-specific group.

    > For example, suppose in my table, I have a boolean
    > field and a date field. I want to create a query
    > asking for those rows where X days have elapsed
    > from the date field in a row and the boolean, say, is false.

    Most databases has built-in-functions to compare dates, but in most cases
    they are database-specific. When you ask such questions, please also make a
    note on which database you're using. If the database conforms to SQL99, I
    don't even think that you need special date-functions.

    > Do I need to create a third field, called, say "X"
    > for how many days have elapsed between the date field
    > and today, and update every row in the table
    > every day?

    No, this should in most cases not be necessary, but you'll have to look up
    in the documentation for the specific database how the Date- and
    Boolean-types are implemented, and which functions you need for the query.

    Just an example, not db-specific and probably wrong for most databases:

      SELECT *
      FROM myTable
      WHERE (CURRENT_DATE - myDateField) >= 10
      AND myBooleanField = TRUE;

    // Bjorn A


  • Next message: Sampsa Sohlman: "Re: JDBC/ODBC user issues accessing SQL Server 2000 database"

    Relevant Pages

    • Re: DBMS and lisp, etc.
      ... Naively implemented with SQL, again for 10 ... (1 query for the initial orders, 1 query for each order for its ... soon as you upgrade to the SQL database. ... (eq (order-customer orderA) ...
      (comp.lang.lisp)
    • Re: OT: SQL
      ... query processing. ... FROM Employees e, Employees m, Management mgt ... Manager and Employee Salaries. ... The scheme used does not model database files in general, ...
      (sci.logic)
    • Re: cannot write to database query
      ... The select query is as shown below, I cannot change the information in the ... What are the SQL views of significant queries? ... What I failed to mention is that this database was fully functioning last ... It has a TRANSFORM clause. ...
      (microsoft.public.access.queries)
    • Re: access 2003
      ... I removed the parameters from the form query source. ... boxes from the form header, events, code, etc and ran the form query source ... forms queries and the SQL because syntax of the SQL will change randomly. ... the Access 97 database, I wouldn't have thought any expressions would be ...
      (microsoft.public.access.conversion)
    • RE: Import external data - web query
      ... Your reply for my query is very extensive, this is for importing a file from ... The data source I want isn't listed in the Select Data Source dialog box. ... information used to connect to a database. ... Check your driver First, make sure you have the right ODBC driver (Open ...
      (microsoft.public.excel.misc)