Skip to content

Instantly share code, notes, and snippets.

@huacnlee
Created August 3, 2010 01:03
Show Gist options
  • Save huacnlee/505627 to your computer and use it in GitHub Desktop.
Save huacnlee/505627 to your computer and use it in GitHub Desktop.
-- MS SQL 对比两个时间相差
-- 结果:10天3小时12分
select
replace(str(datediff(d,getdate(),[due])) + '天' +
str(datediff(hh,getdate(),[due]) % 24) + '小时' +
str(datediff(mi,getdate(),[due]) % 60) + '分钟',' ','') as [remain]
from [users]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment