In a sql server 2008 r2 database, I am trying to obtain just the date portion of a datetime field in mm/dd/yyyy format. I basically just do not want the time portion of this field.
I have used statements like select MONTH(pay_date) + '/' + DAY(pay_date) + '/' + YEAR(payment_date) from cust_table. I keep getting errors.
Can you tell me what is wrong with the above select statement and/or can you show me a different way to obtain only the date in a mm/dd/yyyy format?
Loading
SenthilkumarPosted Dec 8, 2011, 10:40 PM
You no need to do manually.
You can use the convert function with the codes.
SELECT CONVERT(VARCHAR,pay_date,101) FROM cust_table
Thanks,
Senthil.