缘起:
在Access 有一字段是长时间类型的,客户要求做一个日报表汇总,即要把长时间类型改为短时间类型
用Access里的FormatDateTime("LongDate",2) 就可以实现了,但是在Delphi里引用此视图时出错.
提示为:"找不到FormatDateTime函数!!"?? 郁闷ing
解决办法
装 FormatDateTime 函数改为
CDate(CStr(Year(M.CDate))+"-"+CStr(Month(M.CDate))+"-"+CStr(Day(M.CDate)))
问题解决,可是看看这个难看的视图吧.
SELECT CDate(CStr(Year(M.CDate))+"-"+CStr(Month(M.CDate))+"-"+CStr(Day(M.CDate))) AS ShortDate, Sum(S.XiaoJi) AS Sum_XiaoJ, Sum(S.FenCheng) AS Sum_FenCheng, Avg(S.ZheKou) AS Avg_ZheKou, (Select Sum(M1.ShiShou) From RecMain AS M1
Where CDATE(CStr(Year(M1.CDate))+"-"+CStr(Month(M1.CDate))+"-"+CStr(Day(M1.CDate)))=
CDATE(CStr(Year(M.CDate))+"-"+CStr(Month(M.CDate))+"-"+CStr(Day(M.CDate))) and M1.FanSi="付现") AS XianJing, (Select Sum(M1.ShiShou) From RecMain AS M1
Where
CDATE(CStr(Year(M1.CDate))+"-"+CStr(Month(M1.CDate))+"-"+CStr(Day(M1.CDate)))=
CDATE(CStr(Year(M.CDate))+"-"+CStr(Month(M.CDate))+"-"+CStr(Day(M.CDate)))
and
M1.FanSi="刷卡") AS ShuaKa
FROM RecMain AS M INNER JOIN RecSub AS S ON M.id = S.Mid
GROUP BY CDate(CStr(Year(M.CDate))+"-"+CStr(Month(M.CDate))+"-"+CStr(Day(M.CDate)))
ORDER BY CDate(CStr(Year(M.CDate))+"-"+CStr(Month(M.CDate))+"-"+CStr(Day(M.CDate)));
不知道有没有更好的办法