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. Maven setting配置镜像仓库

    国内Maven镜像仓库值得收藏 1.配置IDE构建的Maven存放目录(解压目录) 2.配置IDE的User setting file路径,修改setting配置文件 配置本地仓库   <!-- ...

  2. HTML页面自动跳转,windows操作

    1) html的实现 <head> <!-- 以下方式只是刷新不跳转到其他页面 --> <meta http-equiv="refresh" cont ...

  3. Docker: connection reset by peer

    想来,对docker的学习和实践,已经一年有余了,而我关于这样的文章,只有为数不多的几篇.今天借使用docker中发生的一种异常情况为例,写此篇幅. 这个是在centos7.0 ..netcore2. ...

  4. 002. Asp.Net Routing与MVC 之(基础知识):HttpModule 与 HttpHandler

    本文By 杨工. 一. Http.sys http.sys 从Win2003和WinXP SP2开始,就成为windows操作系统内核驱动程序,能够让任何应用程序通过它提供的接口,以http协议进行信 ...

  5. Java NIO中的通道Channel(一)通道基础

    什么是通道Channel 这个说实话挺难定义的,有点抽象,不过我们可以根据它的用途来理解: 通道主要用于传输数据,从缓冲区的一侧传到另一侧的实体(如文件.套接字...),反之亦然: 通道是访问IO服务 ...

  6. 这是一位拿到BAT大厂offer应届生的年终总结,那么你的呢?

    壹 关于求职 2018年初,我还在北京后厂村的马路上被风吹得瑟瑟发抖. 那时我刚刚结束了半年的实习时光,开始考虑年后是否要继续实习.一开始我也在纠结实习转正和秋招之间如何权衡,但是在经历了春招以后,我 ...

  7. Spring Cloud简介

    一.本文介绍 Web应用由最早的单体应用发展成为集群式的部署,再到现在的分布式系统.尤其是这两年分布式相关的技术发展的很快,一方面是以Dubbo为代表的,另一方面则是以Spring Cloud系列为代 ...

  8. windows下mongodb基础玩法系列一介绍与安装

    windows下mongodb基础玩法系列 windows下mongodb基础玩法系列一介绍与安装 windows下mongodb基础玩法系列二CURD操作(创建.更新.读取和删除) windows下 ...

  9. [转]Using Angular in Visual Studio Code

    本文转自:https://code.visualstudio.com/docs/nodejs/angular-tutorial Using Angular in Visual Studio Code ...

  10. win10 uwp 如何开始写 uwp 程序

    本文告诉大家如何创建一个 UWP 程序. 这是一系列的 uwp 入门博客,所以写的很简单 本文来告诉大家如何创建一个简单的程序 安装 VisualStudio 在开始写 UWP 需要安装 Visual ...