我想在stock_date中将时间设置为00:00:00而不更改年,月或日期,即如果日期表示为07-07-1994 10:45:23
,我想要更改它作为07-07-1994 00:00:00
,我环顾四周,但没有找到任何可能有用的东西。以下是我的查询。感谢。
SELECT stock_date AS longDate,
'Tagged containers' AS transactionType,
tagged_cnt AS quantity
FROM RFID_INVENTORY_DAILY_STOCK
WHERE grp_org_id = (SELECT GRP_ORG_ID
FROM GROUP_ORG_MAPPING
WHERE
grp_id =#group_id#
AND org_type = 'S' AND isactive=1
LIMIT 1)
AND stock_date >= #fromDate#
AND stock_date <= #toDate#
答案 0 :(得分:2)
像这样使用date_trunc
:
SELECT date_trunc('day', current_timestamp);
date_trunc
------------------------
2017-10-06 00:00:00+02
(1 row)