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.
+2
A:
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.
AlexCuse
2008-11-07 18:08:42
and the format of that output is?
Joel Coehoorn
2008-11-07 18:10:11
The format for that is exactly what the OP asked for and is in the language of the DB that was specified. I'm not sure what the down votes are all about.
Tom H.
2008-11-07 19:28:29
The op edited the post after the comment- downvote revoked.
Joel Coehoorn
2008-11-07 19:37:21
+7
A:
Assuming sql server, here is the convert documentation:
http://msdn.microsoft.com/en-us/library/ms187928.aspx
Looking through that, it looks like you want style 103:
SELECT CONVERT(nvarchar(10), getdate(), 103)
Joel Coehoorn
2008-11-07 18:09:31
is there any occasion where this is not as simple as putting an "n" in front of varchar?
AlexCuse
2008-11-13 16:39:14
+1
A:
Geez, I type too slowly...
select CONVERT (NVARCHAR, GETDATE(), 103)
Ken Gentle
2008-11-07 18:10:00