Hi - I have a table with a field that stores date value.
What do i do if i want to get a list of the dates from January1st to today
that are not in this date field.
Thanks a lot!!
First create a new table.
Field Name: MissDate DateTime, Indexed No Duplicates
Name the table tblMissingDates
Next copy and paste the below Sub into a new module to fill the new
table with all the dates from 1/1/2007 to the current date.
Public Sub MissingDates()
Dim Db As DAO.Database
Set Db = CurrentDb
Dim rs As DAO.Recordset
Set rs = Db.OpenRecordset("tblMissingDates")
Dim dteDate As Date
dteDate = #1/1/2007#
Do While dteDate <= Date
With rs
.AddNew
!missdate = dteDate
.Update
dteDate = dteDate + 1
End With
Loop
Set rs = Nothing
Set Db = Nothing
End Sub
Run this sub to fill the table with all of the dates.
Next run the Find Unmatched Query Wizard.
Follow it's instructions.
Below is my sample query to find unmatched records.
Change the field and table names as needed.
SELECT tblMissingDates.*
FROM tblMissingDates LEFT JOIN tblMyTable ON tblMissingDates.MissDate
= tblMyTable.DateField
WHERE (((tblMyTable.DateField) Is Null));
The result will be a query list of all missing dates in tblMyTable.
Note: Make sure all the dates entered in your current table are just
the date, without any time value.