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

This should help. It contains all (or most anyway) the different date formats

http://wiki.lessthandot.com/index.php/Formatting_Dates

I think you'd be better off handling the string conversion in client if possible.


You can convert a date in many formats, in your case :

CONVERT(NVARCHAR(10), YOUR_DATE_TIME, 103) => 15/09/2016
CONVERT(NVARCHAR(10), YOUR_DATE_TIME, 3) => 15/09/16

Syntax:

CONVERT('TheDataTypeYouWant', 'TheDateToConvert', 'TheCodeForFormating' * )

The code is an integer, here 3 is the third formatting option (without century), if you want the century just change the code to 103.

See more at: http://www.w3schools.com/sql/func_convert.asp


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)

Tags:

Sql

Sql Server