Conversion of Oracle TO_CHAR(datetime) with format string to MySQL
The Oracle TO_CHAR(datetime, fmt) function converts datetime values to a string in the format specified by the fmt option.
MySQL has the DATE_FORMAT function that allows datetime values converting to a string in the specified format.
SQLWays converts the Oracle TO_CHAR function to the MySQL DATE_FORMAT function and converts elements of format string from Oracle to corresponding specifier in MySQL as specified in the following table
TABLE 56. Conversion of Oracle TO_CHAR(datetime) with format string to MySQL
Mapping of datetime format specifiers between MySQL and Oracle
MySQL
Oracle (independently from register)
Description
%a
|
DY
|
Abbreviated weekday name (Sun..Sat)
|
%b
|
MON
|
Abbreviated month name (Jan..Dec)
|
%D
|
-
|
Day of the month with English suffix (0th, 1st, 2nd, 3rd, etc.)
|
%d
%e
|
DD
|
Day of the month, numeric ((00..31) and (0..31))
|
%j
|
DDD
|
Day of year (001..366)
|
%m
%c
|
MM
|
Month, numeric ((00..12) and (0..12))
|
%M
|
MONTH
|
Month name (January..December)
|
%f
|
-
|
Microseconds (000000..999999)
|
%i
|
MI
|
Minutes, numeric (00..59)
|
%h
%I
%l
|
HH
HH12
|
Hour ((01..12) and (1..12))
|
%H
%k
|
HH24
|
Hour ((00..23) and (0..23))
|
%p
|
AM
PM
|
AM or PM
|
%r
|
-
|
Time, 12-hour (hh:mm:ss followed by AM or PM)
|
%S
%s
|
SS
|
Seconds ((00..59) and (0..59))
|
%T
|
-
|
Time, 24-hour (hh:mm:ss)
|
%u
|
WW
IW
|
Week (00..53), where Monday is the first day of week
|
%U
|
-
|
Week (00..53), where Sunday is the first day of week
|
%V
|
-
|
Week (01..53), where Sunday is the first day of week, used with %X
|
%v
|
WW
IW
|
Week (01..53), where Monday is the first day of week, used with %x
|
%W
|
DAY
|
Weekday name (Sunday..Saturday)
|
%w
|
-
|
Day of the week (0=Sunday .. 6=Saturday)
|
%X
|
-
|
Year for the week, where Sunday is the first day of the week, numeric 4 digits; used with %V
|
%x
|
-
|
Year for the week, where Monday is the first day of the week, numeric 4 digits; used with %v
|
%Y
|
YYYY
SYYYY
IYYY
|
Year, numeric, 4 digits
|
%y
|
YY
IYY
|
Year, numeric, 2 digits
|
-
|
J
|
Julian day; the number of days since January 1, 4712 BC.
|
-
|
Q
|
Quarter of year (1, 2, 3, 4; JAN-MAR = 1).
|
-
|
RR
|
Given a year with 2 digits:
� If the year is <50 and the last 2 digits of the current year are >=50, then the first 2 digits of the returned year are 1 greater than the first 2 digits of the current year.
� If the year is >=50 and the last 2 digits of the current year are <50, then the first 2 digits of the returned year are 1 less than the first 2 digits of the current year.
|
-
|
RRRR
|
Round year. Accepts either 4-digit or 2-digit input. If 2-digit, provides the same return as RR. If you don't want this functionality, then simply enter the 4-digit year.
|
-
|
W
|
Week of month (1-5) where week 1 starts on the first day of the month and ends on the seventh.
|
-
|
SSSSS
|
Seconds past midnight (0 - 86399).
|
-
|
X
|
Local radix character.
|
-
|
Y,YYY
|
Year with comma in the position.
|
-
|
YEAR
SYEAR
|
Year, spelled out; "S" prefixes BC dates with "-".
|
-
|
YYY
|
3 digits of year.
|
-
|
Y
|
1 digit of year.
|
-
|
IY
|
2 digits of ISO year.
|
-
|
I
|
1 digit of ISO year.
|
-
|
AD
A.D.
|
AD indicator with or without periods.
|
-
|
BC
B.C.
|
BC indicator with or without periods.
|
-
|
CC
SCC
|
One greater than the first two digits of a four-digit year; "S" prefixes BC dates with "-".
For example, '20' from '1900'.
|
-
|
D
|
Day of week (1 - 7).
|
-
|
A.M.
P.M.
|
Meridian indicator with periods.
|
-
|
TZH
|
Time zone hour.
|
-
|
TZM
|
Time zone minute.
|
-
|
TZR
|
Time zone region information.
|
-
|
RM
|
|
TABLE 57. Example of Conversion
Oracle
MySQL
|
|
分享到:
相关推荐
标题“Ascii-Char.zip_char to ascii_conversion”暗示了这个压缩包包含了关于ASCII字符转换的相关内容。ASCII(American Standard Code for Information Interchange,美国信息交换标准代码)是一种基于拉丁字母的...
NFA toDFA conversion and then take string as input and check whether String is acceptable by DFA or not
标题中的"VCCString-int-string-char.txt.rar_conversion_vc string"暗示了我们主要讨论的是VC++中关于字符串与不同数据类型之间的转换,尤其是`std::string`(C++标准库中的字符串类)、`char`数组以及整型`int`...
标题中的"conversion_of_number_system.rar_conversion"暗示我们将讨论一个用C语言编写的数制转换程序,这可能是一个学生为计算机概论课程完成的作业。 数制是表示数字的方法,常见的有二进制(Binary)、八进制...
【标题】"Back_to_Back_HVDC_Conversion_System.rar_Back-To-Back HVDC_back_b" 涉及的核心概念是“背靠背高压直流输电(Back-to-Back HVDC)”系统,这是一种电力传输技术,主要用于连接两个独立运行的交流电网。...
The MATLAB and Praat code files for performing voice conversion. By: Matthew Hutchinson
Dalvik doens t distinguish 64-bits types internally, so this conversion of long to int makes no sense but shall not crash the VM.
Measurement Conversion 1. Length and Distance2. Area3. Volume and Capacity4. Weight and Mass5. Speed6. Temperature
标题中的"ImageConversion_swingdrq_woolo3s_ImageConversion_抓包_MFC_"似乎是一个项目或工具的命名,包含了几个关键元素。首先,“ImageConversion”指涉的是图像转换功能,这通常涉及到图像处理和计算机图形学的...
标题中的"sample-rate-conversion.rar"暗示了这个压缩包涉及的是采样率转换的主题,而"conversion_rate equation_sample rate_"进一步表明它可能包含了关于转换率的数学公式和采样率的概念。采样率在数字信号处理中...
文档的标题为《Razavi Principles of Data Conversion System Design》,这表明文档应该是Behzad Razavi所著的关于数据转换系统设计原理的书籍。 2. 出版信息:文档提供了IEEE Press的出版信息,包括出版社的地址、...
TO_CHAR(NEW_TIME(SYSDATE, 'PDT', 'GMT'), 'YYYY.MM.DD HH24:MI:SS') LOS_ANGLES FROM DUAL; ``` `NEW_TIME`函数用于将一个日期从一个时区转换到另一个时区。在上面的例子中,将北京时区的时间(PDT)转换为了...
标题"utf_string_conversion_utils.rar_conversion"暗示了我们关注的焦点是UTF(Unicode Transformation Format)字符串转换工具,这通常涉及到不同字符编码之间的转换,特别是针对Linux源代码的情况。UTF是一种广泛...
Conversion_of_Infix_to_Postfix 由于我们的计算机系统只能理解和使用二进制语言,因此它假定仅可在两个操作数(例如(A + B)* C(D /(J + D)))中进行假想操作。 这些复杂的关节操作可以两个操作数和一个运算符...
TO_CHAR(date, 'format') 将日期转换为指定格式的字符串。例如: ```sql SELECT TO_CHAR(SYSDATE, 'yyyy/mm/dd hh24:mi:ss') FROM dual; ``` 输出结果为当前日期和时间的字符串表示。 #### 47. TO_DATE(string, '...
读取一个华氏温度的输入,输出开尔文温度 我们设计程序的步骤如下 1. 提示用户键入华氏温度值 2. 读取输入值 3. 通过关系式转换为开氏温度 4. 输出结果,结束
MATLAB脚本"Latitude_And_Longitude_Conversion_Distance.m"实现了这个功能,使得开发者能够轻松地在编程环境中处理这类问题。理解这些概念和算法对于在涉及地理位置的应用中正确计算距离至关重要。
这个“Color_Space_Conversion.rar”压缩包显然包含了关于颜色空间转换的C++程序,利用不同的插值方法来实现这一过程。下面我们将详细讨论颜色空间、颜色插值以及它们在实际应用中的重要性。 首先,颜色空间是定义...
标题中的“165-and-string-conversion.rar_conversion_两片 165”指的是使用AT89S52单片机通过两个74HC165(也常写作165)芯片进行串行到并行的数据转换,以实现LED显示的扩展。74HC165是一款8位串入并出移位寄存器...
【船级社】 ABS Conversion of Self-Elevating Units to Offshore Installations SEU_Conversion_Guide_to_Colors.pdf