vicomin
asked on
format sql date
I have a sql tbl with a column named/data type - start(datetime, not null)
data is like this: 2007-08-31 00:00:00.000
I run this sql stmt - convert(date, start, 110) as 'Open Date'
returns 2007-08-31
but I want it as 8/31/2007
and I have a asp.net page that this data is displayed in a gridview and it is reported as: 8/31/2007 12:00:00 AM
Help?
data is like this: 2007-08-31 00:00:00.000
I run this sql stmt - convert(date, start, 110) as 'Open Date'
returns 2007-08-31
but I want it as 8/31/2007
and I have a asp.net page that this data is displayed in a gridview and it is reported as: 8/31/2007 12:00:00 AM
Help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is some greate date format advice: http://www.sql-server-helper.com/tips/date-formats.aspx
Hi,
For SQL use "convert(varchar, start, 101)" as suggested by pateljitu.
For asp.net, use
Hope this helps.
Thanks!
For SQL use "convert(varchar, start, 101)" as suggested by pateljitu.
For asp.net, use
DateTime dt = new DateTime(2011, 3, 12);
txt1.Text = String.Format("{0:MM/dd/yyyy}", dt);
Hope this helps.
Thanks!
Hi,
Some SQL date formats are here
http://www.sql-server-helper.com/tips/date-formats.aspx
And Have a look on the comments in the below question too
https://www.experts-exchange.com/questions/27040642/Convert-DateTime-value.html
Hope this may help you.
Some SQL date formats are here
http://www.sql-server-helper.com/tips/date-formats.aspx
And Have a look on the comments in the below question too
https://www.experts-exchange.com/questions/27040642/Convert-DateTime-value.html
Hope this may help you.