Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

How does sql convert date to yyyymmdd?

Asked by Dipesh Bhardwaj Mar 13, 2023 1.6K views 1 answer
Share

About this question

Which SQL command is recommended to convert a date to yyyymmdd format?

convert(varchar(8), getdate(), 112); or
convert(varchar, getdate(), 112)
I notice that if I use the second one, it will append two spaces after the date. (e.g. [20130705] - notice the two space after the value 20130705)

Is it recommended to use the first SQL statement?

Your answer

1 Answer

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.