Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert a datetime column to nvarchar with the format DD/MM/YYYY?

Tags:

sql

sql-server

I need to select a datetime column in a table. However, I want the select statement to return the datetime as a nvarchar with the format DD/MM/YYYY.

like image 504
Eldila Avatar asked Nov 07 '08 18:11

Eldila


People also ask

Can we convert datetime to VARCHAR in SQL?

We can convert the DATETIME value to VARCHAR value in SQL server using the CONVERT function. Convert function has three arguments. Let us convert a DATETIME value into VARCHAR with different date styles. And that's how to convert DATETIME value to VARCHAR value in SQL Server!


1 Answers

Here is the convert documentation:

https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql

Looking through that, it looks like you want style 103:

SELECT CONVERT(nvarchar(10), getdate(), 103)
like image 66
Joel Coehoorn Avatar answered Oct 19 '22 05:10

Joel Coehoorn