请提供宝贵的建议,以便对以下mysql查询进行排序。
天给出项目的可用天数,例如:6
Received_date
以此格式显示项目的开始日期,例如:2017-03-27
所以我只需要使用 MYSQL
获取Expired_date
的值
Expired_date (Received_date + days ) = 2017-04-03
请告诉我应该在**某些查询中包含什么**
SELECT
tsc_document_status.warehouse_transfer_note_id,
tsc_document_status.tsc_allocated_days AS days,
tsc_document_status.tsc_accepted_Or_Created_date AS Received_date
(******* some query ****) AS Expired_date
FROM
tsc_document_status
答案 0 :(得分:2)
使用DATE_ADD
功能。
SELECT
t.warehouse_transfer_note_id,
t.tsc_allocated_days AS days,
t.tsc_accepted_Or_Created_date AS Received_date,
DATE_ADD(t.tsc_accepted_Or_Created_date, INTERVAL t.tsc_allocated_days DAY) AS Expired_date
FROM
tsc_document_status AS t