alter session set nls_date_format='YYYY-MM-DD';
select d from table1;
alter session set nls_date_format='YYYY-MM-DD HH24:MISS';
select d from table1;
ได้ผล Code
alter session set succeeded.
D
-------------------------
1987-12-26
1987-12-26
1987-01-26
1987-01-26
1987-01-26
1988-01-26
1987-12-26
2010-01-26
2010-01-27
9 rows selected
alter session set succeeded.
D
-------------------------
1987-12-26 18:2100
1987-12-26 18:2100
1987-01-26 18:2100
1987-01-26 17:2100
1987-01-26 17:2133
1988-01-26 17:2133
1987-12-26 23:3355
2010-01-26 22:3557
2010-01-27 19:2509
9 rows selected
แต่ผ่าน web serv มีปัญหาครับ
appserv 2.5.10 ครับ
Code (PHP)
<?
include"../system/config.php";
function sqq($a){
global $user,$pass,$db,$con;
$parse=oci_parse($con,$a);
echo "sql:ok //$parse //$a<br>";
oci_close($con);
}
function fdate($a){
global $user,$pass,$db,$con;
$parse=oci_parse($con,$a);
oci_execute ($parse,OCI_DEFAULT);
$num=oci_num_fields($parse);
while($db = oci_fetch_array($parse,OCI_BOTH)){
echo $db['PARAMETER']." ".$db['VALUE']."<br>";
}
}
fdate("select * from nls_session_parameters where parameter='NLS_DATE_FORMAT'");
sqq("ALTER SESSION SET NLS_DATE_FORMAT= 'DD-MON-YYYY'");
fdate("select * from nls_session_parameters where parameter='NLS_DATE_FORMAT'");
?>
ได้ผลเป็น แบบ นี้ครับ Code
NLS_DATE_FORMAT DD MON RRRR
sql:ok //Resource id #5 //ALTER SESSION SET NLS_DATE_FORMAT= 'DD-MON-YYYY'
NLS_DATE_FORMAT DD MON RRRR