By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,086 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,086 IT Pros & Developers. It's quick & easy.

Easy way to convert datetime (mysql)

P: n/a
In mysql the db stores date/time as this: yyyy-mm-dd

Is there an easy way to convert it to mm/dd/yyyy?

How about if it shows up in a datagrid column?

How about if the time is appended. For example, my sql is this format:
yyyy-mm-dd hh:ss:mm (no AM/PM)
Nov 6 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Bobby Edward" <bo***@nobody.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
In MySql the db stores date/time as this: yyyy-mm-dd
Yes, that is their default format.
Is there an easy way to convert it to mm/dd/yyyy?
Convert it where? In a query, a stored procedure, during presentation on
screen...?
How about if it shows up in a DataGrid column?
The DataGrid control has been deprecated in favour of the GridView control
since ASP.NET v2.0 - to format data in GridView controls, use something like
this:

<asp:BoundField DataField="MySqlDataField" DataFormatString="{0:mm/dd/yyyy}"
HtmlEncode="false" />

Also, the data format mm/dd/yyyy is ambiguous - in that format, today's date
would be shown as 11/06/2008 which, to most of the Western world, would be
understood as 11th June 2008, not 6th November 2008.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 6 '08 #2

P: n/a
>Is there an easy way to convert it to mm/dd/yyyy?
>
Convert it where? In a query, a stored procedure, during presentation on
screen...?
I want to always display the date/time in this format: mm/dd/yyyy hh:mm
AM/PM

But, I always need to store the date/time in the mysql format: yyyy-mm-dd
hh:mm
I am using XSD datasets which have a built insert/update commands.
The DataGrid control has been deprecated in favour of the GridView control
since ASP.NET v2.0 - to format data in GridView controls, use something
like this:

<asp:BoundField DataField="MySqlDataField"
DataFormatString="{0:mm/dd/yyyy}" HtmlEncode="false" />
Thanks. The DataFormatString should work fine.
>
Also, the data format mm/dd/yyyy is ambiguous - in that format, today's
date would be shown as 11/06/2008 which, to most of the Western world,
would be understood as 11th June 2008, not 6th November 2008.
The requirements are for mm/dd/yyyy. :)
Nov 6 '08 #3

P: n/a
"Bobby Edward" <bo***@nobody.comwrote in message
news:Ox**************@TK2MSFTNGP05.phx.gbl...
>Also, the data format mm/dd/yyyy is ambiguous - in that format, today's
date would be shown as 11/06/2008 which, to most of the Western world,
would be understood as 11th June 2008, not 6th November 2008.

The requirements are for mm/dd/yyyy. :)
Ah, so it's not a public system, then...? Fair enough...
http://en.wikipedia.org/wiki/Image:Date.png
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 6 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.