使用Convert、DATEDIFF 函數求得時間差
SELECT design_product_comment_id, design_product_comment_pid, design_product_comment_username, design_product_comment_text,
design_product_comment_category,
CONVERT(varchar(4), DATEDIFF(day, design_product_comment_date, GETDATE())) AS Days, CONVERT(varchar(4), DATEDIFF(hour, design_product_comment_date, GETDATE()) % 24) AS Hours,
CONVERT(varchar(4), DATEDIFF(minute, design_product_comment_date, GETDATE()) % 60) AS Mins
FROM design_product_comment
WHERE (design_product_comment_pid = @dpid) AND (design_product_comment_category = @cid)"
沒有留言:
張貼留言
留個話吧:)