Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How sqlserver Converts Date Type to Specified Format
How sqlserver Converts Date Type to Specified Format
select convert(char(8),(datepart(year,getdate())* 100+datepart(month,getdate())* 100+datepart(day,getdate()))

+ convert(char(6),(datepart(hour,getdate())* 100+datepart(mi,getdate())* 100+datepart(ss,getdate()))

Just change getdate () to the time you want to convert.

I don't think so. This addition can only be added after conversion to character type. If it is not converted into minutes, it will overflow.

Select convert(char(8), (datepart (year,' 20 10.1.416: 28: 56') *100+datepart (month,' 20/kloc)

+ convert(char(6),(datepart(hour,' 20 10. 1.4 16:28:56 ')* 100+datepart(mi,' 20 10. 1.4 16:28:56 ')* 100+datepart(ss,' 20 10