简体   繁体   中英

How do I find the difference between today's date and X days from today?

Hello all,

Having checked out all the possible threads that were presented before I asked my question, I didn't find an answer suitable for VB.net and MySQL. Most dealt with Android and PHP.

So I'm trying to run a query against a date field in a table within my MySQL database that finds all the records with a date value that's X number of days from today. How would I do this?

I using VS2010 and MySQL - in case I didn't already mention that. Thanks.

//Kismet

MySQL:

SELECT *
FROM table
WHERE DATE(datecol) BETWEEN DATE(NOW()) AND DATE(DATE_ADD(NOW(), INTERVAL x DAY));

See FIDDLE

this is the query for MySQL and

finds all the records with a date value that's X number of days from today

SELECT *
FROM table
WHERE date_column = CURRENT_DATE + INTERVAL X DAY

this one will find all records with a date value between today and X numbers of days from today

SELECT *
FROM table
WHERE date_column BETWEEN CURRENT_DATE AND CURRENT_DATE + INTERVAL X DAY

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM