Oracle time, date type functions and Parameters

Source: Internet
Author: User

Oracle character numeric date conversion  java code  24 hours is shown in the form of HH24     select to_char (sysdate, ' yyyy-mm-dd HH24:mi:ss ') from dual;     select to_date (' 2005-01-01 13:14:20 ', ' yyyy-mm-dd HH24:mi:ss ') from dual;     to_date () function     1. Date format parameter meaning description   d days of the week   day the name of the day, using spaces to fill 9 characters   dd month of the first day of the   ddd year of the day  &N Bsp;dy Day abbreviated name   IW ISO standard year of the week   IYYY ISO standard four-bit year   yyyy four-bit year   yyy,yy,y year last three bits , two-bit, one   hh hour,   hh24 hours by 12 hours, 24 hours   mi minutes   ss seconds   mm Month  &N Bsp The full name of the   month month of the Mon month is   w the first few weeks of the month   WW      1. Date time interval operation    current time minus 7 minutes   select sysdate,sysdate-interval ' 7 ' MINUTE from dual    & nbsp The current time minus 7 hours   select sysdate-interval ' 7 ' hour from dual      current time minus 7 days   select sysdate-interval ' 7 ' date from dual      current time minus July    Select Sysdate,sysdate-interval ' 7 ' month from dual      current time minus 7 years   select Sysdate,sys Date-interval ' 7 ' year from dual      time interval multiplied by a number   select sysdate,sysdate-8 *interval ' 2 ' Hour from dual     2. Date-to-character Operation   select Sysdate,to_char (sysdate, ' Yyyy-mm-dd hh24:mi:ss ') from dual     select Sysdate,to_char (sysdate, ' Yyyy-mm-dd hh:mi:ss ') from dual     select Sysdate,to_char (sysdate, ' YYYY-DDD Hh:mi:ss ') from dual     select Sysdate,to_char (sysdate, ' yyyy-mm iw-d hh:mi:ss ') from dual     3. Character to date operation   select to_date (' 2003-10-17 21:15:37 ', ' yyyy-mm-dd hh24:mi:ss ') from dual      The concrete usage is similar to the to_char above.   4.to_number    convert characters to numbers using the To_number function   to_numBER (char, [' Format '])      numeric format   9 represents a number   0 force display 0   $ Place a $ character  & nbsp L Place a floating local currency symbol   . Display decimal  &nbsp, display the to_date parameter meaning in the thousand indicator     oracle         1. Date format parameter meaning description    d days of the week    day day name, padding to 9 characters with spaces   The day of the  DD month   the day of the  ddd year    dy    IW ISO standard year of the week    IYYY ISO standard four-digit year    YYYY four-bit year    yyy,yy,y year's most Post three-bit, two-bit, one    HH hour, 12-hour meter    HH24 hour, 24-hour meter    mi min    ss sec    MM Month &nbs P  mon    month Month's full name    w week of the month   the first weeks of the  WW year     1. Date and time interval action   when Time minus 7 minutes  select sysdate,sysdate-interval ' 7 ' MINUTE from dual   current time minus 7 hours  select Sysdate-interva L ' 7 ' hour from dual   current time minus 7 days  select sysdate-interval ' 7 ' date from dual   current time minus July  select sy SdAte,sysdate-interval ' 7 ' month from dual   current time minus 7 years  select Sysdate,sysdate-interval ' 7 ' year from dual &N BSP; time interval multiplied by a number  select sysdate,sysdate-8 *interval ' 2 ' hour from dual     2. Date-to-character Operation   sele CT Sysdate,to_char (sysdate, ' Yyyy-mm-dd hh24:mi:ss ') from dual  select Sysdate,to_char (sysdate, ' Yyyy-mm-dd hh:mi: SS ') from dual  select Sysdate,to_char (sysdate, ' yyyy-ddd hh:mi:ss ') from dual  select Sysdate,to_char (sysdate , ' yyyy-mm iw-d hh:mi:ss ') from dual     3. The character-to-date operation   select to_date (' 2003-10-17 21:15:37 ', ' yyyy-mm-dd hh24:mi:ss ') from dual   specific usage is similar to the above To_char.     4. Use of the Trunk/round function   select trunc (sysdate, ' year ') from dual  select trunc (sysdate) from dual  select To_char (Trunc (sysdate, ' YYYY '), ' YYYY ') from dual      5.oracle has a millisecond data type   --Returns the current time, month, day, hour, minute, millisecond, and Nbsp;select To_char (Current_timestamp (5), ' dd-mon-yyyy HH24:MI:SSxFF ') from dual; --returns the second millisecond of the current time, which specifies the precision (max =9) after seconds  select To_char (Current_timestamp (9), ' Mi:ssxff ') from dual;     6. Calculation program run time (MS)   declare  type RC is ref CURSOR;  L_RC RC;  l_dummy All_objects.object_name%type;  l_start number default dbms_utility.get_time;  begin  for I in 1..  loop  open l_rc for   ' select object_name from all_objects ' | |   ' WHERE object_id = ' | | I  fetch L_RC into L_dummy;  close L_RC;  end Loop;  dbms_output.put_line   (Round ((Dbms_utility.get_time-l_start)/100, 2) | |   ' seconds ... ');     end;  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.