I'm trying to insert a row in oracle database and when i try with the date i have the errore in title. My date is DD/MM/YYYY HH:MM:SS
(example 25/01/2013 12:07:19
)
edit for better explain: i have an android application and want to insert a row in oracle database by php.
in Php i have:
$sqlString = sprintf("INSERT INTO GUASTI (%s, %s, %s, %s, %s, %s)
VALUES ('%s', '%s', '%s', '%s', '%s', '%s')"
,'guasto','tipo','data', 'localita', 'indirizzo_id', 'utente_id',
$array['guasto'], $array['tipo'], $array['data'], $array['localita'], $idUtenti, $idIndirizzo);
where $array['data']
is 25/01/2013 12:07:19
ps i know that there are security problems there but it is not a problem for now.
MM
is for month. Use MI
for minutes.
You have
HH:MM:SS
every time where the minutes are greater than 12 will trigger the error as you are telling Oracle to interpret them as months.
You are also using HH without am/pm (in your example you just used 12
). If you are using a 24 format use HH24
DD/MM/YYYY HH24:MI:SS
or if you want the 12-hour format
DD/MM/YYYY HH:MI:SSAM
and then
02/01/2013 07:42:00am
Edit
You are inserting the date with the default format which is MM/DD/YYYY (american standard): 25 is not a valid month. You can use the TO_DATE
function
'TO_DATE(' . $array['data'] . ', DD/MM/YYYY HH24:MI:SS)'
使用TO_DATE('20 / 08/2012 09:00:00','DD / MM / YYYY HH24:MI:SS')插入日期以获取更多详细信息,请参阅链接Oracle错误
Just for more info:
The following pattern letters are defined (all other characters from 'A' to 'Z' and from 'a' to 'z' are reserved):
Letter Date or Time Component Presentation Examples
G Era designator Text AD
y Year Year 1996; 96
Y Week year Year 2009; 09
M Month in year (context sensitive) Month July; Jul; 07
L Month in year (standalone form) Month July; Jul; 07
w Week in year Number 27
W Week in month Number 2
D Day in year Number 189
d Day in month Number 10
F Day of week in month Number 2
E Day name in week Text Tuesday; Tue
u Day number of week (1 = Monday, ..., 7 = Sunday) Number 1
a Am/pm marker Text PM
H Hour in day (0-23) Number 0
k Hour in day (1-24) Number 24
K Hour in am/pm (0-11) Number 0
h Hour in am/pm (1-12) Number 12
m Minute in hour Number 30
s Second in minute Number 55
S Millisecond Number 978
z Time zone General time zone Pacific Standard Time; PST; GMT-08:00
Z Time zone RFC 822 time zone -0800
X Time zone ISO 8601 time zone -08; -0800; -08:00
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.