|
|
|
ต้องทำยังไงครับและอยากให้วันที่แสดงเป็น dd/mm/yyyy = 07/11/2011 |
|
|
|
|
|
|
|
อันนี้ Code ครับ
Code (PHP)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ThaiCreate.Com PHP & SQL Server Tutorial</title>
</head>
<body>
<?
$objConnect = mssql_connect("192.168.1.3\SQL2005","sa","sa191") or die("Error Connect to Database");
$objDB = mssql_select_db("SRI_Golive");
$objQuery = mssql_query("SELECT t0.createdate,t0.createTime FROM oscl t0 WHERE (t0.createdate LIKE '%11%') ");
?>
<table width="800" border="1">
<tr>
<th width="91"> <div align="center">No.</div></th>
<th width="91"> <div align="center">CreateDate</div></th>
<th width="60"> <div align="center">CreateTime</div></th>
</tr>
<?
$i=1;
while($objResult = mssql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$i;?></div></td>
<td><div align="center"><?=$objResult["createdate"];?></div></td>
<td><?=$objResult["createTime"];?></td>
</tr>
<?
$i++;
}
?>
</table>
<?
mssql_close($objConnect);
?>
</body>
</html>
|
|
|
|
|
Date :
2011-11-12 02:54:12 |
By :
งง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ date_format ของ mysql ท่าจะดีกว่านะ
|
|
|
|
|
Date :
2011-11-12 13:10:39 |
By :
ikikkok |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 5 เขียนโดย : webmaster เมื่อวันที่ 2011-11-12 17:40:40
รายละเอียดของการตอบ ::
ผมลอง convert แล้วใน query sql2005 มันแสดงค่าตามต้องการ แต่พอ query มาใส่ใน php มันไม่แสดงตามรูป
Code
Code (PHP)
<html>
<head>
<title>-: Ditto CRM :-</title>
</head>
<body>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" border="0">
<tr>
<th>Keyword
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>">
<input type="submit" value="Search"></th>
</tr>
</table>
</form>
<?
if($_GET["txtKeyword"] != "")
{
$objConnect = mssql_connect("localhost\SQL2005","sa","pass") or die("Error Connect to Database");
$objDB = mssql_select_db("SRI_Golive");
// Search By Name or Email
$strSQL =
//"select createdate,createTime FROM oscl WHERE (createdate LIKE '%".$_GET["txtKeyword"]."%')";
//"SELECT t0.createdate,t0.createTime,t1.block FROM oscl as t0 inner join oins as t1 on t0.insid = t1.insid WHERE (t0.createdate LIKE '%10%') ";
//$numrow = mssql_num_rows($strSQL);
//echo $numrow;
"SELECT CONVERT(varchar(10),T0.createDate,103), T0.createTime, T0.custmrName, T1.street, T1.block, T0.subject, T0.itemCode, T0.internalSN, T0.manufSN, T0.closeTime, T0.closeDate, T4.Name, T3.Name, T2.firstName FROM OSCL T0 INNER JOIN OINS T1 ON T0.insID = T1.insID INNER JOIN OHEM T2 ON T0.technician = T2.empID INNER JOIN OSCT T3 ON T0.callType = T3.callTypeID INNER JOIN OSCS T4 ON T0.status = T4.statusID WHERE (T0.createDate LIKE '%".$_GET["txtKeyword"]."%') AND T2.empID = T0.technician AND T0.callType = T3.callTypeID AND T4.statusID = T0.status ";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="800" border="1">
<tr>
<th width="91"> <div align="center">No.</div></th>
<th width="91"> <div align="center">CreateDate</div></th>
<th width="98"> <div align="center">CreateTime </div></th>
<th width="98"> <div align="center">Customer</div></th>
<th width="98"> <div align="center">Street</div></th>
<th width="98"> <div align="center">Block</div></th>
<th width="98"> <div align="center">Subject</div></th>
<th width="98"> <div align="center">Item</div></th>
<th width="98"> <div align="center">Serial Code</div></th>
<th width="98"> <div align="center">Service Code</div></th>
<th width="98"> <div align="center">Close_Tiam</div></th>
<th width="98"> <div align="center">Close_Date</div></th>
<th width="98"> <div align="center">Service</div></th>
<th width="98"> <div align="center">Technician</div></th>
</tr>
<?
$i=1;
while($objResult = mssql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$i;?></div></td>
<td><div align="center"><?=$objResult["createDate"];?></div></td>
<td><?=$objResult["createTime"];?></td>
<td><?=$objResult["custmrName"];?></td>
<td><?=$objResult["street"];?></td>
<td><?=$objResult["block"];?></td>
<td><?=$objResult["subject"];?></td>
<td><?=$objResult["itemCode"];?></td>
<td><?=$objResult["internalSN"];?></td>
<td><?=$objResult["manufSN"];?></td>
<td><?=$objResult["closeTime"];?></td>
<td><?=$objResult["closeDate"];?></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["firstName"];?></td>
</tr>
<?
$i++;
}
?>
</table>
<?
mssql_close($objConnect);
}
?>
</body>
</html>
|
|
|
|
|
Date :
2011-11-13 20:13:07 |
By :
งง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รอคำชี้แนะ
|
|
|
|
|
Date :
2011-11-14 11:36:48 |
By :
karurub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$sql = "SELECT CONVERT(varchar(10),T0.createDate,103) as createDate , T0.createTime, T0.custmrName, T1.street, T1.block, T0.subject, T0.itemCode, T0.internalSN, T0.manufSN, T0.closeTime, T0.closeDate, T4.Name, T3.Name, T2.firstName FROM OSCL T0 INNER JOIN OINS T1 ON T0.insID = T1.insID INNER JOIN OHEM T2 ON T0.technician = T2.empID INNER JOIN OSCT T3 ON T0.callType = T3.callTypeID INNER JOIN OSCS T4 ON T0.status = T4.statusID WHERE (T0.createDate LIKE '%".$_GET["txtKeyword"]."%') AND T2.empID = T0.technician AND T0.callType = T3.callTypeID AND T4.statusID = T0.status";
CONVERT(varchar(10),T0.createDate,103) as createDate ลองดูนะไม่รู้จาได้ไหม
|
ประวัติการแก้ไข 2011-11-14 16:52:59
|
|
|
|
Date :
2011-11-14 16:52:23 |
By :
LuckyStar |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|