我如何找到今天的日期和今天的 X 天之间的差异? [英] How do I find the difference between today's date and X days from today?

查看:43
本文介绍了我如何找到今天的日期和今天的 X 天之间的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在我提出问题之前检查了所有可能的线程后,我没有找到适合 VB.net 和 MySQL 的答案.大多数处理 Android 和 PHP.

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.

因此,我尝试对 MySQL 数据库中表中的日期字段运行查询,该查询查找日期值为距今天 X 天的所有记录.我该怎么做?

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?

我使用 VS2010 和 MySQL - 如果我还没有提到.谢谢.

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));

参见FIDDLE

这篇关于我如何找到今天的日期和今天的 X 天之间的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆