当前位置:网站首页>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
边栏推荐
- SCHEMA solves the puzzle
- 如何成功通过 CKA 考试?
- How to get the address of WeChat video account (link address of WeChat public account)
- 程序员如何优雅地解决线上问题?
- [CLion] CLion always prompts "This file does not belong to any project target xxx" solution
- .NET性能优化-使用SourceGenerator-Logger记录日志
- 万字解析:vector类
- Qt获取文件夹下所有文件
- [Open class preview]: Research and application of super-resolution technology in the field of video quality enhancement
- 程序员的自我修养
猜你喜欢

《MySQL核心知识》第6章:查询语句

判断JS数据类型的四种方法

Pytest电商项目实战(下)

收藏|机械工程师面试常问问题

Audio and Video Technology Development Weekly | 256
![[Open class preview]: Research and application of super-resolution technology in the field of video quality enhancement](/img/fc/cd859efa69fa7b45f173de74c04858.png)
[Open class preview]: Research and application of super-resolution technology in the field of video quality enhancement

Promise learning (4) The ultimate solution for asynchronous programming async + await: write asynchronous code in a synchronous way

ECCV22|只能11%的参数就能优于Swin,微软提出快速预训练蒸馏方法TinyViT

bpmn-process-designer基础上进行自定义样式(工具、元素、菜单)

安装apex报错
随机推荐
Aeraki Mesh 正式成为 CNCF 沙箱项目
Aeraki Mesh became CNCF sandbox project
Js手写函数之new的模拟实现
leetcode每日一题:字符串压缩
大众碰到点评的一个字体反爬,落地技术也是绝了
[Nodejs] node的fs模块
CloudCompare&PCL ICP配准(点到面)
这项工作事关中小学生生命安全!五部门作出联合部署
Tencent Cloud Native: Service Mesh Practice of Areaki Mesh in the 2022 Winter Olympics Video Live Application
如何利用DevExpress控件绘制流程图?看完这篇文章就懂了!
Visualization of lag correlation of two time series data in R language: use the ccf function of the forecast package to draw the cross-correlation function, and analyze the lag correlation according t
如何设计一个分布式 ID 发号器?
爱可可AI前沿推介(8.1)
OpenHarmony高校技术俱乐部计划发布
MVVM响应式
英特尔全方位打造算力基础,助推“算”赋百业
Dapr 与 NestJs ,实战编写一个 Pub & Sub 装饰器
How to use DevExpress controls to draw flowcharts?After reading this article, you will understand!
故障007:dexp导数莫名中断
Jenkins安装插件遇到的问题