I need to build a date in the yyyy-mm-dd format on an SQL Server.
What’s the best way to do this?
Thanks.
Edit
I did try this
DECLARE @IsoDate varchar(10)
SET @IsoDate = CONVERT(varchar(10), GETDATE(), 120)
Would that be a good approach?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Replace
GetDate()with the column you are using:SELECT CONVERT(VARCHAR(10), GETDATE(), 120) AS [YYYY-MM-DD]And for many other formats / examples consult this: http://www.sql-server-helper.com/tips/date-formats.aspx