Hi I'm in design view for MS Access and I'm creating a query where it selects a list of patients admitted within the last 24 hours. I'm not sure how to do this for my DATE_ADMITTED column, Criteria field. Any help?
If the DATE_ADMITTED field is a real date/time field, then you can set the criteria of the DATE_ADMITTED field to:
That would filter the query results to the past 24 hours down to the second in which the query was run.
For the query to return yesterday and today use:
This should cover from yesterday 12:00:00 AM (midnight) to today 11:59:59 PM (midnight).
Of course the above criteria doesn't check for future dates/times. If on the off chance you need to ensure no future dates/times are included in the query results the two queries below will filter those out.
Website for criteria examples:
Video Series (on Google Video):
When you say last Friday, I take that the previous Friday (not the last Friday of the month or something).
Here is a query that will return the results for the previous Friday, and if executed on a Friday will still return the results of the previous Friday and not the current Friday.
If by 'from last Friday' you meant from the previous Friday until now then here are some criteria depending on the days you want included:
From current or previous Friday until now (if run on a Friday then will return only the current Friday results only)
From previous Friday until now (if run on a Friday it will including current Friday in the results) (Includes current Friday if today is Friday.)
From previous Friday until now (unless run on a Friday, then will be from previous Friday until Thur). (Excludes current Friday, if today is Friday.)
NOT usage - Here is a website that show some examples of NOT.
Hope this helps.