我有一个SQL查询,我需要将DATE
列从Access数据库转换为DATETIME
。
要转换的列是:
CHECKINOUT.CHECKTIME
CHECKINOUT.DefaultIn
CHECKINOUT.DefaultOut
这是我的疑问:
SELECT
USERINFO.NAME, USERINFO.EmployeeCode, CHECKINOUT.CHECKTYPE,
CHECKINOUT.DefaultIn, CHECKINOUT.DefaultOut, CHECKINOUT.DefaultBreckIn,
CHECKINOUT.DefaultBreakOut, CHECKINOUT.CHECKTIME, USERINFO.TITLE
FROM
(CHECKINOUT
INNER JOIN USERINFO ON CHECKINOUT.USERID = USERINFO.USERID)
WHERE
(CHECKINOUT.CHECKTIME >= ?)
AND (CHECKINOUT.CHECKTIME <= ?)
AND (CHECKINOUT.USERID = ? OR ? = - 1)
AND (CHECKINOUT.DefaultIn <= CHECKINOUT.CHECKTIME OR
CHECKINOUT.DefaultOut >= CHECKINOUT.CHECKTIME )
最好的方法是什么?
谢谢
答案 0 :(得分:0)
您必须在查询中使用Format函数,例如:
Format([datetime column],'dd-mm-yyyy @ hh:nn:ss AM/PM')
并在您的SQL中:
SELECT Format([CHECKINOUT.CHECKTIME],'dd-mm-yyyy @ hh:nn:ss AM/PM') AS DT_CHECKTIME ...