Oracle gets the current date and date format
Get system Date: Sysdate ()
Formatted Date: To_char (Sysdate (), ' Yy/mm/dd HH24:MI:SS)
or To_date (Sysdate (), ' Yy/mm/dd HH24:MI:SS)
Formatted number: To_number
Note: to_char Convert a date or number to a string
to_char (number, ' format ')
To_char (Salary, ' $99,999.99 ')
to_char (date, ' format ')
To_date converting a string to a date type in a database
To_date (char, ' format ')
To_number converting a string to a number
To_number (char, ' format ')
return system date, output 2 May-December-09
Select Sysdate from dual;
Mi is minutes, output 2009-12-25 14:23:31
Select To_char (sysdate, ' Yyyy-mm-dd HH24:mi:ss ') from dual;
MM will display the month, output 2009-12-25 14:12:31
Select To_char (sysdate, ' Yyyy-mm-dd HH24:mm:ss ') from dual;
Output 09-12-25 14:23:31
Select To_char (sysdate, ' Yy-mm-dd hh24:mi:ss ') from dual
Output 2009-12-25 14:23:31
Select To_date (' 2009-12-25 14:23:31 ', ' Yyyy-mm-dd,hh24:mi:ss ') from dual
And if you write on the writing:
Select To_date (' 2009-12-25 14:23:31 ', ' Yyyy-mm-dd,hh:mi:ss ') from dual
will be error, because the hour HH is 12 binary, 14 is illegal input, can not match.
Output $10,000,00:
Select To_char (1000000, ' $99,999,99 ') from dual;
Output rmb10,000,00:
Select To_char (1000000, ' l99,999,99 ') from dual;
Output 1000000.12:
Select Trunc (To_number (' 1000000.123 '), 2) from dual;
Select To_number (' 1000000.123 ') from dual;
Format of conversion:
Representing year: Y represents the last of the years,
YY represents the last 2 digits of the year,
YYY represents the last 3 digits of the year,
YYYY 4-digit year
Indicates: mm with 2 digits for month,
Mon in shorthand form, such as November or Nov,
Month with full name, like November or November.
Represents day: DD indicates days of the month,
DDD indicates the day ordinal of the year
Dy when in a few days, shorthand, such as Friday or Fri,
Day when in days, full name, such as Friday or Friday
Represents hour: HH 2 digits represent hours 12 decimal,
Hh24 2-digit hour 24 hour
Represents minute: Mi 2 digits for minutes
Represents second: SS 2 digits for seconds 60 binary
Indicates quarterly: Q A number represents quarter (1-4)
There is also WW used to indicate the week of the year when W is used to denote the month ordinal.
Time range under 24-hour system: 00:00:00-23:59:59
Time range under 12-hour system: 1:00:00-12:59:59
Number format: 9 represents a number
0 Force display 0
$ Place a $ character
l Place a floating local currency symbol
. Show decimal point
, display thousand indicator
Add:
Time minus 7 minutes for the current time
Select Sysdate,sysdate-interval ' 7 ' MINUTE from dual;
The current time minus 7 hours of time
Select Sysdate-interval ' 7 ' hour from dual;
The current time minus 7 days
Select Sysdate-interval ' 7 ' Day from dual;
Time minus July for current time
Select Sysdate,sysdate-interval ' 7 ' month from dual;
Time minus 7 years in the current time
Select Sysdate,sysdate-interval ' 7 ' year from dual;
Time interval multiplied by a number
Select Sysdate,sysdate-8*interval ' 7 ' hour from dual;
Meaning explanation:
Dual Pseudo-column
Dual is an actual table in Oracle that can be read by any user, often in a SELECT statement block without a target table.
Different systems may return dates that are not in the same format.
Returns the currently connected User: Select User from Dual;
Oracle acquisition of system time and format