在项目一开始存储时间把时间分开年,月,日3个字段,没有保存具体的时间,现在需要组装成时间格式参与查询。
现将处理办法做一个整理,以便后期查询,也方便大家
declare @year int
declare @month int
declare @day int
set @year = 2022
set @month = 3
set @day = 16
-- 现组装成时间格式
select replace(cast(@year+@month*0.01 as char(7)),'.','-')+replace(cast(@day * 0.01 as char(4)),'0.','-') time