Reputation: 251
I need a date in the following format: 1.1.2018 So no leading 0 if not needed. I checked the date formats and it doesn't exist this way.
My way would be to build a stored proc or function, converting the date to a varchar and deleting the 0 if needed.
Is there a better solution where I can already get that result without building a stored proc / function?
Any help is greatly appreciated!
Upvotes: 0
Views: 2261
Reputation: 194
--if you are using MSSQL Server
select getdate() 'getdate', (cast(month(getdate()) as varchar)+'.'+cast(day(getdate()) as varchar)+'.'+ cast(year(getdate()) as varchar)) 'getdate_new_format'
Upvotes: 1