Simple SQL Question

Results 1 to 2 of 2

Thread: Simple SQL Question

  1. #1
    Join Date
    Dec 1969

    Default Simple SQL Question

    I am trying to use a select statement to return all records that are less than 31 days from the current date.<BR><BR>I have tried this but it doesn&#039;t seem to work:<BR>Select * From Field1 where Date &#060; (Now) &#060; 31<BR><BR>Does anyone know how I can do this? Thanks in advance.

  2. #2
    Join Date
    Dec 1969

    Default RE: Simple SQL Question

    SQL = "Select * From tableName where DateField &#062;= ( Date() - 31 )"<BR><BR>That&#039;s for Access. For SQL Server:<BR><BR>SQL = "Select * From tableName where DateField &#062;= DateAdd(d,-31,getDate()"<BR><BR><BR>If you really did make the mistake of using "Date" as a field name in your Access DB, then put use [Date] to name the field in your query.<BR><BR><BR><BR>

Posting Permissions

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