|
|
|
|
|
我用 access 2010編寫sql查詢語句,發(fā)現(xiàn) FormatDateTime
這個函數(shù)不能使用,提示:
'FormatDateTime' 函數(shù)未定義
通過試驗,可以用 Format
函數(shù)來代替,例如寫法如下:
Format(dtime,'yyyy-mm-dd hh:nn:ss')
其中,dtime
是時間字段名稱,yyyy-mm-dd hh:nn:ss
是時間格式:年-月-日 時:分:秒。我們也可以格式化成其他的形式,例如:
Format(dtime,'yyyy-mm-dd')
只保留:年-月-日。
下面是一個access的sql查詢語句示例:
select top 10 `age`,Format(dtime,'yyyy-mm-dd') from `log` order by id desc
其中,dtime
是一個時間字段,它的存儲格式是:yyyy-mm-dd hh:nn:ss
,這里把它格式化為 yyyy-mm-dd
的形式。