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.
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!
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With