当前位置:网站首页>formatdatetime函数 mysql(date sub函数)
formatdatetime函数 mysql(date sub函数)
2022-08-01 12:02:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
formatdateTime()函数返回表达式,此表达式已被格式化为日期或时间 表达式 formatdateTime(Date, [, Namedformat]) 允许数据类型: Namedformat 指示所使用的日期/时间格式的数值,如果省略,则使用 vbGeneralDate.
NamedFormat参数的设置值如下: 常数 值 描述 vbGeneralDate 0 显示日期和/或时间。如果有日期部分,则用短日期格式显示。如果有时间部分,则用长时间格式显示。如果都有,两部分都显示。 vbLongDate 1 用计算机区域设置值中指定的长日期格式显示日期。 vbShortDate 2 用计算机区域设置值中指定的短日期格式显示日期。 vbLongTime 3 用计算机区域设置值中指定的时间格式显示时间。 vbShortTime 4 用24小时格式(hh:mm)显示时间。
Format参数是一个格式化字符串。DateTime是时间类型。返回值是一种格式化后的字符串,重点来看Format参数中的指令字符:
c 以短时间格式显示时间,即全部是数字的表示 FormatdateTime(‘c’,now); 输出为:2004-8-7 9:55:40
d 对应于时间中的日期,日期是一位则显示一位,两位则显示两位 FormatdateTime(‘d’,now); 输出可能为1~31 dd 和d的意义一样,但它始终是以两位来显示的 FormatdateTime(‘dd’,now); 输出可能为01~31 ddd 显示的是星期几 FormatdateTime(‘ddd’,now); 输出为: 星期六 dddd 和ddd显示的是一样的。 但上面两个如果在其他国家可能不一样。 ddddd 以短时间格式显示年月日 FormatdateTime(‘ddddd’,now); 输出为:2004-8-7 dddddd 以长时间格式显示年月日 FormatdateTime(‘dddddd’,now); 输出为:2004年8月7日
e/ee/eee/eeee 以相应的位数显示年 FormatdateTime(‘ee’,now); 输出为:04 (表示04年)
m/mm/mmm/mmmm 表示月 FormatdateTime(‘m’,now); 输出为:8 FormatdateTime(‘mm’,now); 输出为 08 FormatdateTime(‘mmm’,now); 输出为 八月 FormatdateTime(‘mmmm’,now); 输出为 八月 和ddd/dddd 一样,在其他国家可能不同
yy/yyyy 表示年 FormatdateTime(‘yy’,now); 输出为 04 FormatdateTime(‘yyyy’,now); 输出为 2004
h/hh,n/nn,s/ss,z/zzz 分别表示小时,分,秒,毫秒 t 以短时间格式显示时间 FormatdateTime(‘t’,now); 输出为 10:17 tt 以长时间格式显示时间 FormatdateTime(‘tt’,now); 输出为10:18:46
ampm 以长时间格式显示上午还是下午 FormatdateTime(‘ttampm’,now); 输出为:10:22:57上午
如果要在Format中加普通的字符串,可以用双引号隔开那些特定义的字符,这样普通字符串中如果含特殊的字符就不会被显示为时间格式啦: FormatdateTime(‘”today is” c’,now); 输出为:today is 2004-8-7 10:26:58
时间中也可以加”-“或”/”来分开日期: FormatdateTime(‘”today is” yy-mm-dd’,now); FormatdateTime(‘”today is” yy/mm/dd’,now); 输出为: today is 04-08-07
也可以用”:”来分开时间 FormatdateTime(‘”today is” hh:nn:ss’,now); 输出为:today is 10:32:23
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/126689.html原文链接:https://javaforall.cn
边栏推荐
- 【likeshop】回收租凭系统100%开源无加密 商城+回收+租赁
- 找出相同属性值的对象 累加数量 汇总
- 用户体验 | 如何度量用户体验 ?
- 如何设计一个分布式 ID 发号器?
- 表连接详解
- pgAdmin 4 v6.12 发布,PostgreSQL 开源图形化管理工具
- .NET性能优化-使用SourceGenerator-Logger记录日志
- 【CLion】CLion 总是提示 “This file does not belong to any project target xxx” 的解决方法
- Find objects with the same property value Cumulative number Summarize
- [Open class preview]: Research and application of super-resolution technology in the field of video quality enhancement
猜你喜欢
随机推荐
CAN通信的数据帧和远程帧
Process sibling data into tree data
万字解析:vector类
Qt get all files in a folder
轮询和长轮询的区别
《MySQL核心知识》第6章:查询语句
A new generation of ultra-safe cellular batteries, Sihao Airun goes on sale starting at 139,900 yuan
每日一题:连续子数组的最大和(动态规划)
Several methods of appending elements are commonly used in js: append, appendTo, after, before, insertAfter, insertBefore, appendChild
字体反爬之好租
Audio and Video Technology Development Weekly | 256
【Unity3D插件】AVPro Video插件分享《视频播放插件》
win10系统重装,无法登录进行同步的情况下chrome数据恢复
英特尔全方位打造算力基础,助推“算”赋百业
【随心笔记】假期快过去了,都干了点什么
Grafana9.0发布,Prometheus和Loki查询生成器、全新导航、热图面板等新功能!
[Nodejs] node的fs模块
Data frame and remote frame of CAN communication
Beyond Compare 4 试用期到期
如何使用 Authing 单点登录,集成 Discourse 论坛?








