record count based on current date (Today's date) - sql

I have a form in which I enter a record and I have a field that automatically updates with the current date. I would like to add a subform that tells me how many records have been entered "today" based on current date (today's date). I would like it to keep a running total. I am new to asking questions in this format and appreciate any help and understanding.

For Access:
SELECT COUNT(*) FROM ... WHERE add_date BETWEEN DATE() AND DATE()+1;
as suggested by David W. Fenton in the comments.

Related

Max Date Last Update Date SQL

I am asking for help with this item. I am a novice to SQL and not very sure how to handle this problem I appreciate any help from the forum.
I have a table that is updated multiple times a day. I would like to create a view that only displays the last update that was made for a given day.
Here is a sample of the data
enter image description here
This is the desired result of the SQL Query when the data set provided has been queries
enter image description here
As I understood you want to get the last record of every day.
Just group it by day
You will have to use EXTRACT to do it
Example: EXTRACT(DAY FROM DATE)
Then select the max time from the column where you have the time of the day. If you dont have the time in a different column you will also need to extract it.
SELECT MAX(TIME_COLUMN) FROM `TABLE_NAME`
GROUP BY EXTRACT(DAY FROM DATE)
SELECT MAX (your_date) AS "Max Date"
FROM your_table

There's duplicated query result in Microsoft Access while checking for time overlapping

I got a table with a huge list of equipment booking details. I wrote a SQL Query to display the desired result that I wanted: A type of the equipment with time overlapping of booking.
So I check for the time overlapping by duplicating my table in order for it to check against each other.
The result I gotten are kind of repetitive?
For instance,
May CLASHES Claire
May CLASHES Sherene
Claire CLASHES May
Claire CLASHES Sherene
Sherene CLASHES May
Those in bold are repetitive.
How can I modify my SQL query in order to resolve the issue?
Please kindly advise. Thank you!
SELECT DISTINCT *
FROM 2015, 2015 AS 2015_1
WHERE ([2015].Equipment Like '*Video cam*' Or [2015].Equipment Like '*video recorder*' Or [2015].Equipment Like '*camcorder*')
AND ([2015_1].Equipment Like '*Video cam*' Or [2015_1].Equipment Like '*video recorder*' Or [2015_1].Equipment Like '*camcorder*')
AND ([2015].[Loaned By]<>[2015_1].[Loaned By])
AND ([2015_1].[Start Time]<=[2015].[End Time])
AND ([2015_1].[End Time] Is Null Or [2015_1].[End Time]>=[2015].[Start Time]);
EDIT
My table is called 2015.
The variables are (Field Name - Data Type):
ID - Number
Loaned By - Text
Equipment - Text
Start Date - Date/Time
Start Time - Date/Time
End Date - Date/Time
End Time - Date/Time
Durations (hours) - Number
You can add the following condition:
[2015].EquipmentType < [2015_1].EquipmentType
This will order them alphabetically.
Your question doesn't have enough information to clearly specify the column.

displaying records with a date at least one day greater then or = to today

I have a field in a table called DATEF. It displays dates as follows: 2013-11-25 08:30:00.000. The field is used to show appointment dates. What I need to show are future appointment dates from today or = to today. (Getdate) for some reason this is not working for me today. Appreciate the help. Thank you.
Try this... you're probably failing to factor in the time component. (This is for SQL Server, you'll have to find the equivalent for your respective environment)
SELECT <SOMETHING>
FROM TABLE
WHERE DATEF >= CONVERT(DATE,GETDATE())

Between Date Range in a QUERY Not Working

I have a Date for Example a Departure Date of a Flight for 15/01/2014 and I want to create a query that remind me 30 days before departure.
I tried the following in the CRITERIA but none of them work
DateAdd("m",1,[DepartureDate])>=Date()
Between DateAdd("m",1,[DepartureDate]) And [DepartureDate]
IIF(DateAdd("m",1,[DepartureDate]) < Date(), True, False)
You posted this quite a while ago, so I presume you managed to solve it. But if not, here is an answer for you.
There are two ways to do this.
Option One
The easiest way is to enter this in the CRITERIA of your DepartureDate field:
=Date()+30
Option Two
Alternatively, you could create a new column in your query that you filter on. To do this in your query, enter this in the FIELD row for a new column:
30DaysAway: IIf([DepartureDate]-30=Date(),"yes","no")
This will give you a new column in the query titled "30DaysAway". In that column it will say "yes" if the departure date is 30 days away from today, and "no" for all other dates.
Then in the CRITERIA for that query field, enter "yes".
Either of these options will filter the list of results and only show you entries with a departure date that is 30 days away.

How to extract dates with datatye DATETIME from colum A in table X and put them into Table Y while changing datatype into DATE

Long title, easy meaning:
How is it possible to extract from a date like "2014-04-04 10:47:30.000", which is stored in one column, it's components like year, month and day?
I'm not interested in the time.
For example, I have a table called "Incidents". Inside the table we got a column called "IncidentID" and a column called "ReportingDate", in which dates like the above-mentionend are stored. Let's say we have about 50k Incidents, therefore we have also 50k dates.
A year has 365 days. I want to query for the count of the Incidents, which were reported on different dates - for instance on the 5th of October 2013.
So: How can I get the components of the date and put them into another table while having own columns for the components and how can I query for the Incidents as well?
I guess at first I have to change the datatype of the date from DATETIME to DATE, but I'm not quite sure how to go further. May anyone help me while giving me a code and explains me what it does for a sql-noob? :-)
To achieve this
I want to query for the count of the Incidents, which were reported on
different dates - for instance on the 5th of October 2013.
you haven't do this:
I guess at first I have to change the datatype of the date from
DATETIME to DATE, but I'm not quite sure how to go further.
Just query
SELECT
IncidentID
FROM incidents
WHERE ReportingDate >= '20131005'
AND ReportingDate < '20131006'