Calculating the "Age" of a Record as a Field

Results 1 to 2 of 2

Thread: Calculating the "Age" of a Record as a Field

  1. #1
    Join Date
    Dec 1969

    Default Calculating the "Age" of a Record as a Field

    I have an MS Access database, and a table named "SpyReports". There is a a Date/Time field in that table named "UploadDate" which stores the creation date of that record.<BR><BR>In an SQL query, I need to determine how many days old all these records are. In ASP, I would use the DateDiff function <BR><BR>DateDiff("d", Now, UploadDate)<BR><BR>Is there a way to incorporate this into an SQL statement so the "Age" can be a caculated field that I can retrieve and/or sort by? Help is appreciated, thanks :-)

  2. #2
    007 Guest

    Default Datediff works in Access

    A table called SpyReports... who do you work for?<BR><BR>Try something like this:<BR><BR>Sql = "Select UploadDate, DateDiff(&#039;d&#039;,[UploadDate],Date()) As RecordAge From SpyReports"<BR><BR>Set rsOldSpies=ObjConn.Execute(Sql)<BR><BR>Response.Wr ite "Record created on:" & rsOldSpies("UploadDate") & " is " & rsOldSpies("RecordAge") " days old."

Posting Permissions

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