两个日期内有多少个星期 [英] How many weeks are inside of two dates
问题描述
如何得到答案,这两个日期里有几周(或几天)? (mysql或php)
例如我有这样的数据库:
will_end
2009-12-17 | 2009-12-24
2009-12-12 | 2009-12-26
...
更新到问题:
如何使用DATEDIFF?
我该如何让这个工作?或者我应该以不同的方式使用DATEDIFF?
SELECT DATEDIFF('Started','will_end')AS'Duration'FROM my_table WHERE id ='110';
MySQL具有 datediff ,它返回两个日期之间的差异,因为MySQL 4.1.1。
<请注意,根据手册,
DATEDIFF(expr1,expr2)
返回 expr1 - expr2
表示为从一个日期到另一个日期的天数。 expr1和expr2是日期或日期和时间表达式。 I have starting dates and ending dates in my database (MySQL). How can I get the answer, how many weeks(or days) are inside of those 2 dates? (mysql or php)
For example I have this kind of database:
Started and | will_end
2009-12-17 | 2009-12-24
2009-12-12 | 2009-12-26
...
Update to the question:
How to use DATEDIFF?
How can I make this to work? or should I use DATEDIFF completly differently?
SELECT DATEDIFF('Started ','will_end') AS 'Duration' FROM my_table WHERE id = '110';
MySQL has datediff which returns the difference in days between two dates, since MySQL 4.1.1.
Do note that, as per the manual, DATEDIFF(expr1,expr2)
returns expr1 – expr2
expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation.
这篇关于两个日期内有多少个星期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!