Searching a range of dates in a Microsoft Access 2013 form query -
i trying search database using form user can enter start date , end date , return results. have been trying these forums have said, results getting except range want. data omitted.
i tried switching around start/end date fields didn't work.
here have right returns opposite results:
like "*" & (([uut_result].[start_date_time]) between [forms]![testformresults]![startdatetime] , [forms]![testformresults]![enddatetime]) & "*"
where (([uut_result].[start_date_time]) between [forms]![testformresults]![startdatetime] , iif([forms]![testformresults]![enddatetime] null, date(), [forms]![testformresults]![enddatetime])
what iif()
evaluates condition, enddatetime = null
. if null, aka isnull(enddatetime) = true
, returns value if true piece, today's date. if isnull(enddatetime) = false
, meaning there date in control, return value if false, in case [forms]![testformresults]![enddatetime]
.
the *
wildcard in sql. used find variations of combinations of search criteria.
select [fields] [table] ((yourdatefield) between #[first date]# , #[second date]#)
this assuming field names correctly referred to. #
signs hard-coded dates. using form control referencing not require them (your syntax dates fine.)
Comments
Post a Comment