I have a database in which I want to execute a query that takes an integer. The query finds the user who has not back up the system for xx (integer) amount of days.<br><br>The database has a entity called LastModified that when displayed on the screen takes the format such as:<br><br>4/4/00 11:07:44 PM<br>the date part is in the mm/dd/yy format.<br><br>the table that holds the entity LastModified is called FileDescription and the value I want to find is the CustID ,that is also an entity of the FileDescription table.<br><br>I want to know how to write the query so that it takes the integer from the text box measures it against the current date to find who has backed up in that time period. So for example if I entered 30 into the text box, the SQL query would work out how many customers (CustID) backed up in the last 30 days.<br><br>I'm using MS SQL server, but I'm really having difficulty with using dates/times. Heres a breakdown of my problem.<br><br>I have a date field used in my database, when I see this date on the SQL server after I have run a query the date is shown as e.g. : 2000-02-18 19:14:59.660<br><br>When a run the query on an asp page, the date is shown as e.g.: 1/26/98 3:45:32 PM<br><br>Heres a snippet of the code that gives me problems :<br><br>------------------------------------<br><br>dLastMod = DateAdd("d", -5, Now())<br>Response.Write "Current Date: " & Now() & "<br>"<br>Response.Write "Find Date:" & dLastMod & "<br>"<br>Response.Write FormatDateTime(dLastMod,2) & "<br>"<br>datelast = FormatDateTime(dLastMod,2)<br>datelast = datelast & "12:00:00 AM"<br>Response.Write datelast & "<br>"<br>Response.Write "Backup Works" & request.form("days" & "<br>"<br><br>StrQuery = "Select CustId from FileDescription where FileDescription.UploadDate > " & dLastMod<br><br>----------------------------------------<br><br>The problem I suspect is with the query itself.<br><br>Heres the error message I get:<br><br>--------------------------------------<br>Microsoft OLE BD Provider for ODBC Drivers error '80040e14'<br><br>Incorrect syntax near '11' <-(the time part)<br>line 35, <-(StrQuery line)<br>---------------------------------------------<br><br>I have tried using the date part (datelast in code above) by itself but this just shows all the records in the database.<br><br>If you need more info plz tell me.<br>I posted this message before but got no reply, it has serveral replys that did'nt help. The topic was called<br>"SQL query involving a date, plz help!!"<br>I would be extremly grateful for any help.<br><br>Taha