Getting first day of the week in MySql using Week No(使用 Week No 在 MySql 中获取一周的第一天)
问题描述
如何获得周数可用的给定周的第一天?
How do I get the first day of a given week whose week number is available?
例如,当我写这篇文章时,我们在 WEEK 29.我想编写一个 MySQL 查询,该查询将使用这个 WEEKNO 返回 Sunday 18 29 作为唯一可用的参数.
For example as I write this post we are at WEEK 29.I would like to write a MySQL query that will return Sunday 18 July using this WEEKNO 29 as the only available parameter.
推荐答案
您可以使用:
SELECT STR_TO_DATE('201003 Monday', '%X%V %W');
这将为您提供 2010 年第 3 周的星期一日期,即 2010-01-18.
This would give you the Monday date of week 3 of 2010, which would be 2010-01-18.
另一个例子:
SELECT STR_TO_DATE('201052 Sunday', '%X%V %W');
将为您提供 2010 年第 52 周的星期日日期,即 2010-12-26.
Would give you the Sunday date of week 52 of 2010, which would be 2010-12-26.
最后,使用您的原始示例:
And finally, using your original example:
SELECT STR_TO_DATE('201029 Sunday', '%X%V %W');
这给出了 2010-07-18.
This gives 2010-07-18.
这篇关于使用 Week No 在 MySql 中获取一周的第一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Week No 在 MySql 中获取一周的第一天
基础教程推荐
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- oracle区分大小写的原因? 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在多列上分布任意行 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
