SELECT to_char(MAX(update_timestamp), 'yyyymmddhh24miss.sssss') lastUpadateTime
FROM t_itemorder
WHERE itemorder_num = '184'
return : 20060123164734.60454 FROM t_itemorder
WHERE itemorder_num = '184'
SELECT to_char(SYSDATE, 'yyyy/mm/dd HH24:MI:SS') FROM dual
return : 2006/03/01 10:33:17Get MAX Update_timestamp Method
public static string QueryLastUpadateTime(int stockCorrectNum)
{
StringBuilder sb = new StringBuilder();
sb.Append("SELECT MAX(update_timestamp) lastUpadateTime FROM t_stockCorrect ");
sb.AppendFormat("WHERE stockCorrect_num = {0}", stockCorrectNum);
string sql = sb.ToString();
object obj = OracleHelper.ExecuteScalar(sql);
if (obj == DBNull.Value)
{
return "";
}
return ((DateTime)obj).ToString(BaseRecord.TimeFormat);
}
return : 20060123164734000{
StringBuilder sb = new StringBuilder();
sb.Append("SELECT MAX(update_timestamp) lastUpadateTime FROM t_stockCorrect ");
sb.AppendFormat("WHERE stockCorrect_num = {0}", stockCorrectNum);
string sql = sb.ToString();
object obj = OracleHelper.ExecuteScalar(sql);
if (obj == DBNull.Value)
{
return "";
}
return ((DateTime)obj).ToString(BaseRecord.TimeFormat);
}
另:
public class BaseRecord
{
private static readonly ILog log = LogManager.GetLogger(typeof(BaseRecord));
public static readonly int NullNumber = int.MinValue;
public static readonly string IntegerFormat = "#,##0";
public static readonly string DecimalFormat = "#,##0.00";
public static readonly string DateFormat = "yyyyMMdd";
public static readonly string TimeFormat = "yyyyMMddHHmmssfff";
}
{
private static readonly ILog log = LogManager.GetLogger(typeof(BaseRecord));
public static readonly int NullNumber = int.MinValue;
public static readonly string IntegerFormat = "#,##0";
public static readonly string DecimalFormat = "#,##0.00";
public static readonly string DateFormat = "yyyyMMdd";
public static readonly string TimeFormat = "yyyyMMddHHmmssfff";
}
在 DataGrid 中的 DataFormatString 属性
<asp:BoundColumn HeaderText="UpdateTime" DataField="UpdateTime" DataFormatString="{0:yyyy-MM-dd hh:mm:ss}">
</asp:BoundColumn>
</asp:BoundColumn>