我目前正在处理以下查询,但我希望我的结果以hh:mm
格式显示。我使用的是convert(char, mycolumnName, 108)
,但我的结果仍显示为hh:mm:ss
。我只需要hh:mm
。有没有办法如何在hh:mm
中获得此结果?请建议提前谢谢!
select distinct
clientid, timein , timeout, calculation,
convert(char, calculation, 108) as CalculationResult
from
calculationTable
where
timein is not null and timeout is not null
输出:
Clientid timein timeout calculation CalculationResult
------------------------------------------------------------------------
0012345 09:00:00 05:00:00 1900-01-01 08:00:00 08:00:00
答案 0 :(得分:1)
SELECT DISTINCT clientid,
timein,
timeout,
calculation,
convert(VARCHAR(5), calculation, 108) AS CalculationResult
FROM calculationTable
WHERE timein IS NOT NULL
AND timeout IS NOT NULL
答案 1 :(得分:0)
试试这个
select
distinct clientid,
timein,
timeout,
calculation,
convert(varchar(5), calculation, 108) as CalculationResult