当前位置:网站首页>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
边栏推荐
- Meshlab & Open3D SOR filtering
- 数字化转型实践:世界级2B数字化营销的方法框架
- bat countdown code
- Dapr 与 NestJs ,实战编写一个 Pub & Sub 装饰器
- Programmer's self-cultivation
- Online - GCeasy GC log analysis tools
- 判断JS数据类型的四种方法
- Hot review last week (7.25 7.31)
- Stone Technology builds hard-core brand power and continues to expand the global market
- R语言检验时间序列的平稳性:使用tseries包的adf.test函数实现增强的Dickey-Fuller(ADF)检验、检验时序数据是否具有均值回归特性(平稳性)、具有均值回归特性的案例
猜你喜欢
Pytest电商项目实战(下)
Programmer's self-cultivation
如何利用DevExpress控件绘制流程图?看完这篇文章就懂了!
Dameng replaces the officially authorized dm.key
Beyond Compare 4 试用期到期
[Open class preview]: Research and application of super-resolution technology in the field of video image quality enhancement
The CAN communication standard frame and extended frame is introduced
基于ArkUI eTS开发的坚果食谱(NutRecipes)
小程序插件如何帮助开发者受益?
实现集中式身份认证管理的案例
随机推荐
pgAdmin 4 v6.12 发布,PostgreSQL 开源图形化管理工具
The use of Ts - Map type
Istio Meetup China: Full Stack Service Mesh - Aeraki Helps You Manage Any Layer 7 Traffic in an Istio Service Mesh
SCHEMA解惑
(ES6以上以及TS) Map对象转数组
一篇文章,带你详细了解华为认证体系证书(2)
mysql进阶(二十二)MySQL错误之Incorrect string value中文字符输入错误问题分析
.NET analyzes the LINQ framework in depth (three: the elegant prelude of LINQ)
R language ggplot2 visualization: use the ggdensity function of the ggpubr package to visualize density plots, use the stat_central_tendency function to add mean vertical lines to the density and cust
Envoy 源码流程图
Dapr 与 NestJs ,实战编写一个 Pub & Sub 装饰器
【讲座分享】“营收“看金融
字体反爬之好租
bat倒计时代码
Data frame and remote frame of CAN communication
Envoy source code flow chart
Alibaba Cloud Official Redis Development Specification
C language implementation!20000 in 4 seconds
How to Integrate Your Service Registry with Istio?
(ES6 and above and TS) Map object to array