Datetime Format Element Suffixes

Suffix Meaning Example Element Example Value
TH Ordinal Number DDTH 4TH
SP Spelled Number DDSP FOUR
SPTH or THSP Spelled, ordinal number DDSPTH FOURTH

Notes on date format element suffixes:

  • When you add one of these suffixes to a datetime format element, the return value is always in English.
  • Datetime suffixes are valid only to format output. You cannot use them to insert a date into the database.

Format Model Modifiers

FM

Fill mode. Oracle uses blank characters to fill format elements to a constant width equal to the largest element for the relevant format model in the current session language. For example, when NLS_LANGUAGE is AMERICAN, the largest element for MONTH is SEPTEMBER, so all values of the MONTH format element are padded to 9 display characters. This modifier suppresses blank padding in the return value of the TO_CHAR function:

  • In a datetime format element of a TO_CHAR function, this modifier suppresses blanks in subsequent character elements (such as MONTH) and suppresses leading zeroes for subsequent number elements (such as MI) in a date format model. Without FM, the result of a character element is always right padded with blanks to a fixed length, and leading zeroes are always returned for a number element. With FM, which suppresses blank padding, the length of the return value may vary.
  • In a number format element of a TO_CHAR function, this modifier suppresses blanks added to the left of the number, so that the result is left-justified in the output buffer. Without FM, the result is always right-justified in the buffer, resulting in blank-padding to the left of the number.

FX

Format exact. This modifier specifies exact matching for the character argument and datetime format model of a TO_DATE function:

  • Punctuation and quoted text in the character argument must exactly match (except for case) the corresponding parts of the format model.
  • The character argument cannot have extra blanks. Without FX, Oracle ignores extra blanks.
  • Numeric data in the character argument must have the same number of digits as the corresponding element in the format model. Without FX, numbers in the character argument can omit leading zeroes.When FX is enabled, you can disable this check for leading zeroes by using the FM modifier as well.

If any portion of the character argument violates any of these conditions, then Oracle returns an error message.

Format Model Examples



SELECT TO_CHAR(SYSDATE, 'fmDDTH')||' of '||TO_CHAR
(SYSDATE, 'fmMonth')||', '||TO_CHAR(SYSDATE, 'YYYY') "Ides"
FROM DUAL; Ides
------------------
3RD of April, 1998 SELECT TO_CHAR(SYSDATE, 'DDTH')||' of '||
TO_CHAR(SYSDATE, 'Month')||', '||
TO_CHAR(SYSDATE, 'YYYY') "Ides"
FROM DUAL; Ides
-----------------------
03RD of April , 1998 SELECT TO_CHAR(SYSDATE, 'fmDay')||'''s Special' "Menu"
FROM DUAL; Menu
-----------------
Tuesday's Special

参考:

[1]: https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34924 'Oracle Format Models'

[2]: https://www.cnblogs.com/reborter/archive/2008/11/28/1343195.html 'Oracle to_char格式化函数'

oracle 日期格式化 TO_CHAR (datetime) 修饰语和后缀的更多相关文章

  1. Oracle日期格式化以及extract函数的使用

    由于业务需要,这两天在学习Oracle,发现Oracle里面的日期它会给你转成一种很不习惯的格式,于是想着怎么样把它弄成年.月.日的格式来显示,查资料.看文档,最终找到解决办法了,其实是用到了to_c ...

  2. oracle日期格式化

    TO_CHAR(t.CAMERA_CREAT_TIME, 'YYYY-MM-DD HH24:MI:SS') as point_registerdate,TO_CHAR(t.CAMERA_MODIFY_ ...

  3. oracle 日期格式化和数据去重

    1.获取系统日期: select sysdate as date1 from dual: 当前时间减去7分钟的时间 select sysdate,sysdate - interval '7' MINU ...

  4. Oracle 英文 非标准格式 日期 格式化

    最近在处理一张表的时候,需要按照日期排序,日期字段中日期的格式有两种. 格式一:07-Aug-2015 格式二:10/28/16 日期转化及格式化sql语句: select to_date('07-A ...

  5. C# DateTime日期格式化

    在C#中DateTime是一个包含日期.时间的类型,此类型通过ToString()转换为字符串时,可根据传入给Tostring()的参数转换为多种字符串格式. 目录 1. 分类 2. 制式类型 3. ...

  6. django datetime format 日期格式化

    django datetime format 日期格式化 www.jx-lab.com python 中 date,datetime,time对象都支持strftime(format)方法,但有一些区 ...

  7. Python时间日期格式化之time与datetime模块总结

    1 引言 在实际开发过程中,我们经常会用到日期或者时间,那么在Python中我们怎么获取时间,以及如何将时间转换为我们需要的格式呢?在之前的开发中,也曾遇到time.datetime等模块下的不同函数 ...

  8. c#根据当前时间获取本周,本月,本年度等时间段和DateTime日期格式化

    DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays( - Convert.ToInt32(dt.DayOfWeek.T ...

  9. ORACLE——日期时间格式化参数详解 之一

    2.日期格式化参数详解 2.1 -/,.;: 指定返回字串分隔符 SQL> select to_char(sysdate,'yyyy.mm.dd') from dual; TO_CHAR(SYS ...

随机推荐

  1. 课程四(Convolutional Neural Networks),第四 周(Special applications: Face recognition & Neural style transfer) —— 2.Programming assignments:Art generation with Neural Style Transfer

    Deep Learning & Art: Neural Style Transfer Welcome to the second assignment of this week. In thi ...

  2. 06-TypeScript中的表达式

    TypeScript中提供了箭头表达式,通过箭头表达式可以简化我们的编码. 1.箭头表达式简化匿名函数 在JS中,我们通常使用匿名函数,匿名函数实际上是赋值给一个变量,常见的写法如下: var sun ...

  3. php 对数组按照字符串长度排序

    $file = file('zong.txt'); usort($file, 'sortByLen'); $handle = fopen('zong2.txt', 'a'); foreach ($fi ...

  4. 【OSX】解决编译AOSP时需要10.5/10.6 SDK下载

    有人遇到的是需要10.6的sdk. 公司网快下载了xcode, 把里面的10.5sdk和10.6sdk拿出来, 一共才一百多兆…… 下载链接: http://pan.baidu.com/s/1gdxG ...

  5. 给recycleview加headview

    参考了https://blog.csdn.net/qibin0506/article/details/49716795 由于recycleview没有直接添加头部view的api,所以需要我们自己去添 ...

  6. Git学习系列之Windows上安装Git详细步骤(图文详解)

    前言 最初,Git是用于Linux下的内核代码管理.因为其非常好用,目前,已经被成功移植到Mac和Windows操作系统下. 鉴于大部分使用者使用的是Windows操作系统,故,这里详细讲解Windo ...

  7. Oracle的数据并发与一致性详解(下)

    上篇介绍了数据并发与一致性的相关概念.以及oracle的事务隔离级别等内容,本篇继续介绍锁机制.自动锁.手动锁.用户自定义锁的相关内容. 请尊重作者劳动成果,转载请标明原文链接: https://ww ...

  8. CSS hack兼容表

    IE6 IE7 IE8 Firefox Opera Safari !important Y Y Y Y Y _ Y * Y Y *+ Y \9 Y Y Y \0 Y nth-of-type(1) Y ...

  9. springboot+cloud 学习(三)消息中间件 RibbitMQ+Stream

    安装RabbitMQ window下安装: (1):下载erlang,原因在于RabbitMQ服务端代码是使用并发式语言erlang编写的,下载地址:http://www.erlang.org/dow ...

  10. Jmeter配置通过SSH连接的mysql数据库

    jmeter连接配置mysql数据库时,如果数据库服务器没有通过ssh连接,则只需要添加配置相应的jdbc参数就可以了.如果数据库服务器是通过SSH连接的,则需要通过中间远程连接工具来登录,此处使用的 ...