1. Use the Oracle method to_date ();
String DateStr = "1985-07-11 10:30:00. 0 ";
Pstmt = conn. prepareStatement ("insert into t (d) VALUES (to_date (?, 'Yyyy-MM-DD HH24: MI: ss ')");
Pstmt. setString (1, DateStr)
2. java. SQL. Date is different from java. util. Date. The former is a subclass. The parameter type of the pstmt. setDate method is SQL.
In Java, System.currenttimemillis () takes the number of milliseconds from 1970-01-01 00:00:00.000 to the current time, a long value.This value is now accessed in a table in the Oracle database and needs to be converted to a readable date type.Current Millis provides conversion results for timemillis and some common conversio
Label:httpjava Use osio Data forart
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 paramete
Oracle time and String Conversion Year: yy two digits two-Year display value: 07yyy three digits three-Year display value: 007 yyyy four digits four-digit Year display value: 2007 Month: mm number two-month display value: 11mon abbreviated Character Set indicates display value: January 1, November. If the English version is used, nov month spelled out Character Set indicates display value: January 1, Novemb
1.
Date and character conversion function usage (to_date, to_char)
2.Select to_char (to_date (222, 'J'), 'jsp ') from dual
Display two hundred twenty-two
3.The day of the week.Select to_char (to_date ('1970-08-26 ', 'yyyy-mm-dd'), 'day') from dual;MondaySelect to_char (to_date ('1970-08-26 ', 'yyyy-mm-dd'), 'day', 'nls _ date_language = American') from dual;MondaySet the
; -- Automatic transformation
Example 3: Format a number and display it in currency format.
Select To_char (' 4758475847583 ', ' 9,9999,9999,9999 ') from dual;Select To_char (' 4758475847583 ', ' l9,999,999,999,999 ') from dual;
two , Change a string to a dateExample 4: Converting the specified string to a date by format
Select To_date (' 2017-11-21 ', ' YYYY-MM-DD ') from dual;
three ,
Type conversion rules between Oracle and c in the Pro * C program:
VARCHAR2 (n)
Char [n + 1]
CHAR
Char [1 + 1]
CHAR (n)
Char [n + 1]
NUMBER
VARCHAR [38 + 2]
NUMBER (p)
Int p Double 10 VARCHAR [n] p> = 16
NUMBER (p, s)
P P> = 16: VARCHAR [n]When s When s> 0:P> s: n = p + 2P
DATE
C
maximum value and adds 1
fromPx_fxrecordreturn @FxNum
End
ALTER TABLEPx_fxrecordADD DEFAULT([dbo].[F_getfxnum]()) forFxnum--bind the function to Fxnum as the default value for the field Parameter description: Right (Str,len) -The field returns the rightmost Len character string strMax () -the largest value in the fieldIsNull () -Determines whether the content is empty convert () -format conversion Oracle
Tags: Java uses OS data for AR Art codeReproduced:To_date () with 24-hour notation and MM-minute display:One, when using Oracle's to_date function to do date conversion, many Java programmers may use the "YYYY-MM-DD HH:mm:ss" format as a format for conversion, but in Oracle will cause an error: "ORA 01810 The format co
--Start
Oracle provides the corresponding functions for each data type, and generally the conversion between them is very simple, and Oracle provides functions such as:
CAST converts one type to another type To_date the string into a DATE To_timestamp converts the string to a TIMESTAMP to_timestamp_t Z converts the st
I. Data Control Statement (DML)
1. insert (insert the record statement into the data table)
Insertinto table name (field name 1, field name 2 ,......) Values (value 1, value 2 ,......);Insertinto table name (field name 1, field name 2 ,......) Select (field name 1, field name 2 ,......) From another table name;
Field Values of the string type must be enclosed in single quotes, for example, 'goodday'If the field value contains single quotes and requires String
Oracle has two time types: Date and timestamp. Date, accurate to seconds, and timestamp to milliseconds.
1. Calculate the time difference of the date type
You can set the year, month, day, hour, minute, and second first.Use the to_char function to split the data and convert it to a value type using the to_number
To_date formatDay:DD Number 12DY abbreviated FriDay spelled out FridayDdspth spelled out, ordinal twelfthMonth:MM Number 03Mon abbreviated MarMonth spelled out MarchYear:YY two digits 98YYYY four digits 1998 24-hour format of the time range: 0:00:00-23:59:59 ....12-hour format of the time range: 1:00:00-12:59:59 .... 1.Date and character conversion function usage (TO_DATE,TO_CHAR) 2.Select To_char (to_date
Oracle-20SEP-date format conversion to 9-20 and compare size date format conversion: SQL> select to_char (to_date ('01sep', 'ddmon ', 'nls _ date_language = American '), 'Mm-dd') from dual; TO_CHAR (TO_DATE ('01sep ', 'ddmon ------------------------------ 09-01 compare the s
Error: ORA-26041: DATETIME/interval data type conversion error.
When a problem occurs, you are running a non-English language environment and loading an Oracle that contains a DATE or DATETIME data type in batches.
To avoid this problem, set the Oracle date language environm
Oracle inversion inversion function Oracle provides a reverse inversion function reverse, but this function cannot be grouped upside down, this article provides a function that can be grouped upside down, as follows: CREATE OR REPLACE FUNCTION reverse_f (p_str VARCHAR2, P_delimiter varchar2:= ")Return VARCHAR2 isV_return VARCHAR2 (4000);VP_STR VARCHAR2 (4000): = P_STR;V_IDX number;Vp_len Number: = Length (P
Tags: time conversion OracleHttp://www.cnblogs.com/hanyun/archive/2009/05/14/1456772.html1). When using Oracle's To_date function for date conversion, it is possible to intuitively convert in "YYYY-MM-DD HH:mm:ss" format as a format, but in Oracle it causes an error: "ORA 01810 format code two times". such as: Select T
The time in oracle is converted to the string to_char (), the string conversion time to_date (), and the use of substr and instr ., To_charto_date
A statement written at work
Select * from Bt_Holiday whereTo_char (Setting_DATE, 'yyyy') = Substr ('2017-03-00 ', 2015) AND
To_char (Setting_DATE, 'mm') = Substr ('2017-03-00 ', 6, (instr ('2017-03-00', '-', 2015 )) -(instr ('2017-03-00 ','-', 1) + 1 ))
Substr
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.