I have a table where I select customer purchase activity and it will display the date of purchase (along with the time) in ColumnA, in this format:
2012-08-06 10:06:42.223
YYYY-MM-DD HH:MM:SS
I want to display the date only, so I added a LEFT function like so:
LEFT(ColumnA, 11)
This will get rid of the time but now the date is displayed I will get:
Aug 06 2012
I want to display it in numeric format but as MM/DD/YYYY so it will look like:
08/06/2012
MM/DD/YYYY
Any ideas how I can do this in T-SQL?
You just need to convert it:
or from your table:
Here is a handy website with the conversions:
How to format datetime & date in Sql Server 2005
Or if you just want yourDate value without the time, you can always use which results in
2012-08-06 00:00:00.000:Or from yourTable: