MySQL 日期

沉沦 2017-07-14 05:25:46
1. 我输入2个时间 . 2017-05-01 , 2017-05-05

2. 我不希望借助任何实体表,函数,存储过程得到以下结果


结果 :

2017-05-01
2017-05-02
2017-05-03
2017-05-04
2017-05-05


PS : 我的思路是先2个日期相减得到 2017-05-01, 2017-05-02, 2017-05-03, 2017-05-04 , 2017-05-05

希望我说清楚了..

...全文
225 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ACMAIN_CHM 2017-07-19
  • 打赏
  • 举报
回复
set @d1='2017-05-01'; set @d2='2017-05-05'; select @d1+interval sq day as mydate from ( select 0 as sq union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9 union all select 10 union all select 11 union all select 12 union all select 13 union all select 14 union all select 15 union all select 16 union all select 17 union all select 18 union all select 19 union all select 20 union all select 21 union all select 22 union all select 23 union all select 24 union all select 25 union all select 26 union all select 27 union all select 28 union all select 29 union all select 30 union all select 31 union all select 32 union all select 33 union all select 34 union all select 35 union all select 36 union all select 37 union all select 38 union all select 39 union all select 40 union all select 41 union all select 42 union all select 43 union all select 44 union all select 45 union all select 46 union all select 47 union all select 48 union all select 49 union all select 50 union all select 51 union all select 52 union all select 53 union all select 54 union all select 55 union all select 56 union all select 57 union all select 58 union all select 59 union all select 60 union all select 61 union all select 62 union all select 63 union all ) t where @d1+interval<=@d2
wsy24680 2017-07-17
  • 打赏
  • 举报
回复
用时间戳加个循环计算
zjcxc 2017-07-17
  • 打赏
  • 举报
回复
确定的两值值,可以拼 sql 出来结果,不确定的值,那就无法拼了
二月十六 2017-07-16
  • 打赏
  • 举报
回复
系统函数也不能用吗?
本课程是SQL系列课程第2篇:MySQL数据库。MySQL篇    MySQL数据库管理系统安装        10.1 MySQL概述            10.1.1 MySQL主要特点            10.1.2 MySQL主要版本         10.2 MySQL数据库安装和配置            10.2.1 Windows平台安装MySQL                1.下载MySQL8.0社区版                2.安装MySQL8.0社区版            10.2.2 Linux平台安装MySQL                1.更新软件仓库包索引                2.安装 MySQL                3.防火墙设置                4.启动 MySQL 服务                5.配置远程登录            10.2.3 macOS平台安装MySQL                1.下载MySQL8.0社区版                2.安装 MySQL    MySQL数据库管理系统日常管理        11.1 登录服务器        11.2 常见的管理命令            11.2.1 帮助命令            11.2.2 退出命令            11.2.3 数据库管理            11.2.4 用户管理        11.3 查看系统对象信息            11.3.1 查看有哪些库            11.3.2 查看有哪些表            11.3.3 查看表结构        11.4 执行脚本文件            11.4.1 不需要登录MySQL方式            11.4.2 需要登录MySQL方式        11.5 数据库备份与恢复            11.5.1 备份数据库            11.5.2 恢复数据库            11.5.3 实例:在Windows下备份到Linux下恢复        11.6 MySQL图形界面管理工具            11.6.1 下载和安装MySQL Workbench            11.6.2 配置连接数据库            11.6.3 管理数据库            11.6.4 管理表            11.6.5 执行SQL语句    MySQL中特有的SQL语句        12.1 自增长字段        12.2 MySQL日期相关数据类型        12.3 限制返回行数        12.4 常用函数            12.4.1 数字型函数            12.4.2 字符串函数            12.4.3 日期和时间函数    MySQL数据库开发        13.1 存储过程            13.1.1 使用存储过程重构“找出所有销售部所有员工信息”案例            13.1.2 调用存储过程            13.1.3 删除储过程        13.2 存储过程参数            13.2.1 IN参数            13.2.2 OUT参数            13.2.3 INOUT参数        13.3 存储函数            13.3.1 创建存储函数            13.3.2 调用存储函数            13.3.3 删除存储函数        13.4 触发器            13.4.1 触发器分类            13.4.2 创建触发器语法            13.4.3 使用NEW和OLD修饰符            13.4.4 示例:员工表操作更新日志            13.4.5 测试触发器

56,682

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧