仅更改BIGINT类型的日期时间戳记的时间
问题描述:
我想在stock_date中将时间设置为00:00:00而不更改年份,月份或日期,即如果日期表示形式为07-07-1994 10:45:23
,我希望将其改为07-07-1994 00:00:00
我环顾四周,但没有找到任何可能有所帮助的东西。以下是我的查询。谢谢。仅更改BIGINT类型的日期时间戳记的时间
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#
答
使用date_trunc
这样的:
SELECT date_trunc('day', current_timestamp);
date_trunc
------------------------
2017-10-06 00:00:00+02
(1 row)