日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle fx成立时间,oracle 日期格式FM/FX和日期后缀SP/TH/SPTH/THSP

發布時間:2023/12/14 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle fx成立时间,oracle 日期格式FM/FX和日期后缀SP/TH/SPTH/THSP 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、日期后綴

oracle的日期后綴,有SP、TH、SPTH/THSP幾種

在oracle的官方聯機文檔上有,有如下描述:

摘錄表格如下:

TH是序數方式顯示,SP是用字母拼寫方式顯示.

THSP或SPTH,就是兩種方式都有。

--普通方式顯示,月份后面,有很大的空格。

SQL> SELECT TO_CHAR(SYSDATE, 'DD') || ' of '? ||

2???????? TO_CHAR(SYSDATE, 'Month') || ', ' ||

3???????? TO_CHAR(SYSDATE, 'YYYY') "Ides"

4? FROM DUAL;

Ides

-------------------------------------------------

07 of May????? , 2014

--序數方式顯示,月份后面也一樣有個大空格。

SQL> SELECT TO_CHAR(SYSDATE, 'DDTH') || ' of '||

2???????? TO_CHAR(SYSDATE, 'Month')|| ', '? ||

3???????? TO_CHAR(SYSDATE, 'YYYY') "Ides"

4??FROM DUAL;

Ides

--------------------------------------------------

07TH of May????? , 2014

--改變Dd的大小寫,th的大小寫也會變化

SQL> SELECT TO_CHAR(SYSDATE, 'DdTH') || ' of '||

2???????? TO_CHAR(SYSDATE, 'Month')|| ', '? ||

3???????? TO_CHAR(SYSDATE, 'YYYY') "Ides"

4??FROM DUAL;

Ides

--------------------------------------------------

07th of May????? , 2014

--改變dd的大小寫,th的大小寫也會變化

SQL> SELECT TO_CHAR(SYSDATE, 'ddTH')|| ' of '||

2???????? TO_CHAR(SYSDATE, 'Month') || ', ' ||

3???????? TO_CHAR(SYSDATE, 'YYYY') "Ides"

4??FROM DUAL;

Ides

--------------------------------------------------

07th of May????? , 2014

-- SP是字母拼寫方式顯示

SQL>? SELECT TO_CHAR(SYSDATE, 'DDsp') || ' of ' ||

2????????? TO_CHAR(SYSDATE, 'Month') || ', ' ||

3????????? TO_CHAR(SYSDATE, 'YYYY') "Ides"

4?? FROM DUAL;

Ides

----------------------------------------------------

SEVEN of May????? , 2014

-- SPTH和THSP是字母拼寫和序數方式顯示

SQL> SELECT TO_CHAR(SYSDATE, 'DDSPTH') || ' of ' ||

2???????? TO_CHAR(SYSDATE, 'Month') || ', ' ||

3????????? TO_CHAR(SYSDATE, 'YYYY') "Ides"

4??FROM DUAL;

Ides

---------------------------------------------------------

SEVENTH of May????? , 2014

二、FM和FX格式

The FM and FX modifiers, used in format models in the TO_CHAR function, control blank padding and exact format checking.

FM和FX主要是用來控制填充和精確格式。

FM Fill mode. Oracle uses trailing blank characters and leading zeroes

to fill format elements to a constant width. The width is equal to the

display width of the largest element for the relevant format model:

Numeric elements are padded with leading zeros to the width of the

maximum value allowed for the element. For example, the YYYY element is

padded to four digits (the length of '9999'), HH24 to two digits (the

length of '23'), and DDD to three digits (the

length of '366').

The character elements MONTH, MON, DAY, and DY are padded with

trailing blanks to the width of the longest full month name, the longest

abbreviated month name, the longest full date name, or the longest

abbreviated day name, respectively, among valid names

determined by the values of NLS_DATE_LANGUAGE and NLS_CALENDAR

parameters. For example, when NLS_DATE_LANGUAGE is AMERICAN and

NLS_CALENDAR is GREGORIAN (the default), the largest element for MONTH

is SEPTEMBER, so all values of the MONTH format element are

padded to nine display characters. The values of the NLS_DATE_LANGUAGE

and NLS_CALENDAR parameters are specified in the third argument to

TO_CHAR and TO_* datetime functions or they are retrieved from the NLS

environment of the current session.

The character element RM is padded with trailing blanks to the length of 4, which is the length of 'viii'.

Other character elements and spelled-out numbers (SP, SPTH, and THSP suffixes) are not padded.

The FM modifier suppresses the above padding in the return value of the TO_CHAR function.

fm是填充模式

如果是字符格式化,指定fm參數后將僅返回指定屬性實際所占長度(不再以空格填充)。

如果是數值格式化,fm參數會自動舍棄被格式化元素的前置0。

--序數方式顯示,并且fm方式顯示,會把多余的前綴0和多余的空格去掉。

SQL> SELECT TO_CHAR(SYSDATE, 'fmDDTH') || ' of ' ||

2???????? TO_CHAR(SYSDATE, 'fmMonth') || ', ' ||

3???????? TO_CHAR(SYSDATE, 'YYYY') "Ides"

4??? FROM DUAL;

Ides

------------------------------------------------------------

7TH of May, 2014

--字母拼寫方式顯示,并且fm方式顯示,會把多余的前綴0和多余的空格去掉。

SQL> SELECT TO_CHAR(SYSDATE, 'fmDDTHSP') || ' of ' ||

2???????? TO_CHAR(SYSDATE, 'fmMonth') || ', ' ||

3???????? TO_CHAR(SYSDATE, 'YYYY') "Ides"

4? FROM DUAL;

Ides

-----------------------------------------------------

SEVENTH of May, 2014

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 zeros.

When FX is enabled, you can disable this check for leading zeros by using the FM modifier as well.

fx是精確匹配模式,使用FX格式后:

1.字符及對應的格式必須嚴格一一對應,甚至連分隔符都要相符。

2.不允許有多余的空格。

3.數值參與格式需要完全對應(或通過fm參數去掉前置0)

SQL> select to_date('2014-5-10','yyyy-mm-dd') from dual;SQL> select to_date('2014-5-10','yyyy-mm-dd') from dual;

TO_DATE('201

------------

10-MAY-14

SQL> select to_date('2014-5-10','yyyy/mm/dd') from dual;

TO_DATE('201

------------

10-MAY-14

SQL> select to_date('2014-5-10','fxyyyy-mm-dd') from dual;

select to_date('2014-5-10','fxyyyy-mm-dd') from dual

*

ERROR at line 1:

ORA-01862: the numeric value does not match the length of the format item

SQL> select to_date('2014-5-10','fxyyyy/mm/dd') from dual;

select to_date('2014-5-10','fxyyyy/mm/dd') from dual

*

ERROR at line 1:

ORA-01861: literal does not match format string

SQL> select to_date('2014-05-10','fxyyyy-mm-dd') from dual;

TO_DATE('201

------------

10-MAY-14

SQL> select to_date('2014-5-10','fxyyyy-fmmm-dd') from dual;

TO_DATE('201

------------

10-MAY-14 10-MAY-14

總結

以上是生活随笔為你收集整理的oracle fx成立时间,oracle 日期格式FM/FX和日期后缀SP/TH/SPTH/THSP的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。