WEEKOFYEAR(NOW())vs WEEK('2018-05-1')-当前日期 [英] WEEKOFYEAR(NOW()) vs WEEK('2018-05-1') - the current date

查看:85
本文介绍了WEEKOFYEAR(NOW())vs WEEK('2018-05-1')-当前日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道是否有人可以阐明为什么进行以下查询(注意:今天的日期是2018年5月1日)

SELECT WEEKOFYEAR(NOW()); 给出的结果为 18 .

just wondering if anyone can shed some light on why why the following query (Note: today's date is 1 May 2018)

SELECT WEEKOFYEAR(NOW()); gives a result of 18.

但查询: SELECT WEEK('2018-05-1')(使用所有不同的模式0 -7)给出的结果为 17 ?

BUT the query: SELECT WEEK('2018-05-1') (using all the different modes 0 -7) gives a result of 17?

因为今天是2018年5月5日,所以NOW()的一年中的一周在技术上是否应与2018-05-01的一年中的一周相同?

Shouldn't the week of year for NOW() technically be the same as the week of the year for: 2018-05-01 since today is the 5th of May 2018?

很好奇为什么没有给出相同的结果.

Very curious as to why its not giving the same result.

非常感谢

推荐答案

weekoftheyear()函数中,周号将从一年的第一天开始.

In weekoftheyear() function, Week number will start from the 1st day of the year.

Week()功能中,星期几"将从一年的第一个星期一开始.

In Week() function, Week bymber will start from 1st Monday of the year.

这篇关于WEEKOFYEAR(NOW())vs WEEK('2018-05-1')-当前日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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