Answer the question
In order to leave comments, you need to log in
How to write a query with a date?
How to write a request with a date correctly (I can’t write it correctly because I can’t understand)
"Display the number of new products in the store - products that were delivered during the last week (7 days)" I
did this:
SELECT COUNT(Product.idProduct) FROM Product WHERE Product.idProduct IN
(SELECT Dalivery.idProduct FROM Dalivery
WHERE (YEAR(Dalivery.DateDelivery) BETWEEN YEAR(DATE_ADD(GETDATE(), INTERVAL -7 DAY)) AND GETDATE() ) );
Answer the question
In order to leave comments, you need to log in
stupidly difference in days between date and "today":
the difference is less than or equal to 7 - for the last 7 days
, but if a "hit" in a calendar week is required, the expression will be somewhat more poignant
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question