当前位置:网站首页>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
边栏推荐
- 华硕和微星多款产品将升级英特尔Arc A380和A310显卡
- CloudCompare&PCL ICP配准(点到面)
- js中常用追加元素的几种方法:append,appendTo,after,before,insertAfter,insertBefore,appendChild
- 关于亚马逊测评,你了解多少?
- 新书上市 |《谁在掷骰子?》在“不确定性时代”中确定前行
- [Open class preview]: Research and application of super-resolution technology in the field of video image quality enhancement
- 找出相同属性值的对象 累加数量 汇总
- Fault 007: The dexp derivative is inexplicably interrupted
- Stone Technology builds hard-core brand power and continues to expand the global market
- [5 days countdown] to explore the secret behind the great quality promotion, gift waiting for you to take of $one thousand
猜你喜欢
A new generation of ultra-safe cellular batteries, Sihao Airun goes on sale starting at 139,900 yuan
稀疏表示--学习笔记
华硕和微星多款产品将升级英特尔Arc A380和A310显卡
英特尔全方位打造算力基础,助推“算”赋百业
表达式引擎在转转平台的实践
Promise learning (4) The ultimate solution for asynchronous programming async + await: write asynchronous code in a synchronous way
达梦更换正式授权dm.key
【公开课预告】:超分辨率技术在视频画质增强领域的研究与应用
程序员如何优雅地解决线上问题?
CloudCompare & PCL ICP registration (point to face)
随机推荐
MarkDown公式指导手册
leetcode每日一题:字符串压缩
[CLion] CLion always prompts "This file does not belong to any project target xxx" solution
易周金融分析 | 银行ATM机智能化改造提速;互联网贷款新规带来挑战
初级必备:单例模式的7个问题
ACL 2022 | 文本生成的相关前沿进展
程序员如何优雅地解决线上问题?
如何设计一个分布式 ID 发号器?
【面试高频题】难度 1.5/5,二分经典运用题
CAN通信标准帧和扩展帧介绍
MVVM响应式
那些利用假期学习的职场人,后来都怎么样了?
【倒计时5天】探索音画质量提升背后的秘密,千元大礼等你来拿
每日一题:连续子数组的最大和(动态规划)
R语言诊断ARIMA模型:forecast包构建了一个ARIMA模型、使用checkresiduals函数诊断ARIMA模型、并进行结果解读(拟合较差的ARIMA模型具有的特点)
SCHEMA solves the puzzle
The use of Ts - Map type
阿里云官方 Redis 开发规范
万字解析:vector类
Deep understanding of Istio - advanced practice of cloud native service mesh