I have the following line FormatDateTime(dsEdit.FieldValue("BDateStart", Container),2)
which is currently displaying the date as MM/DD/YYYY when I need YYYY/MM/DD to suit my database (MySQL)
How can I go about formatting the date to suit my needs?
With FormatDateTimeyou have a limited range of formatting options see http://msdn2.microsoft.com/en-us/library/a912f2a0(VS.80).aspx
Change FormatDateTime(dsEdit.FieldValue("BDateStart", Container),2)
to dsEdit.FieldValue("BDateStart", Container).ToString("yyyy/MM/dd")
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
With FormatDateTimeyou have a limited range of formatting options see http://msdn2.microsoft.com/en-us/library/a912f2a0(VS.80).aspx
Change FormatDateTime(dsEdit.FieldValue("BDateStart", Container),2)
to dsEdit.FieldValue("BDateStart", Container).ToString("yyyy/MM/dd")
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
With FormatDateTimeyou have a limited range of formatting options see http://msdn2.microsoft.com/en-us/library/a912f2a0(VS.80).aspx
Change FormatDateTime(dsEdit.FieldValue("BDateStart", Container),2)
to dsEdit.FieldValue("BDateStart", Container).ToString("yyyy/MM/dd")
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
System.IFormatProvider xIFormatProvider = new CultureInfo("en-GB", true); dsEdit.FieldValue("BDateStart", Container).ToString(xIFormatProvider,"yyyy/MM/dd")
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
CultureInfo xIFormatProvider = new CultureInfo("en-GB", true);
dsEdit.FieldValue("BDateStart", Container).ToString(xIFormatProvider,"yyyy/MM/dd");
Click "Mark as Answer" on the post that helped you.
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
adam_leerox
0 Points
8 Posts
Date Format (YYYY/MM/DD) From (MM/DD/YYYY)
Apr 24, 2007 04:39 AM|LINK
I am very new to asp.net (started this week)
I have the following line FormatDateTime(dsEdit.FieldValue("BDateStart", Container),2) which is currently displaying the date as MM/DD/YYYY when I need YYYY/MM/DD to suit my database (MySQL)
How can I go about formatting the date to suit my needs?
Thankyou
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Date Format (YYYY/MM/DD) From (MM/DD/YYYY)
Apr 24, 2007 06:15 AM|LINK
With FormatDateTimeyou have a limited range of formatting options see http://msdn2.microsoft.com/en-us/library/a912f2a0(VS.80).aspx
Change FormatDateTime(dsEdit.FieldValue("BDateStart", Container),2)
to dsEdit.FieldValue("BDateStart", Container).ToString("yyyy/MM/dd")
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Date Format (YYYY/MM/DD) From (MM/DD/YYYY)
Apr 24, 2007 06:17 AM|LINK
With FormatDateTimeyou have a limited range of formatting options see http://msdn2.microsoft.com/en-us/library/a912f2a0(VS.80).aspx
Change FormatDateTime(dsEdit.FieldValue("BDateStart", Container),2)
to dsEdit.FieldValue("BDateStart", Container).ToString("yyyy/MM/dd")
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Date Format (YYYY/MM/DD) From (MM/DD/YYYY)
Apr 24, 2007 06:18 AM|LINK
With FormatDateTimeyou have a limited range of formatting options see http://msdn2.microsoft.com/en-us/library/a912f2a0(VS.80).aspx
Change FormatDateTime(dsEdit.FieldValue("BDateStart", Container),2)
to dsEdit.FieldValue("BDateStart", Container).ToString("yyyy/MM/dd")
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
fahiemulleh
Member
232 Points
91 Posts
Re: Date Format (YYYY/MM/DD) From (MM/DD/YYYY)
Apr 24, 2007 06:19 AM|LINK
Response.Write(dt.ToString(
"yyyy/MM/dd"));Please mark this post as RESOLVED.
adam_leerox
0 Points
8 Posts
Re: Date Format (YYYY/MM/DD) From (MM/DD/YYYY)
Apr 24, 2007 09:53 PM|LINK
Thankyou for your reply.
I tried the above and got the following error:
Compiler Error Message: BC30311: Value of type 'String' cannot be converted to 'System.IFormatProvider'.
On the line which had the change?
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Date Format (YYYY/MM/DD) From (MM/DD/YYYY)
Apr 25, 2007 11:32 AM|LINK
Change
dsEdit.FieldValue("BDateStart", Container).ToString("yyyy/MM/dd")
to
System.IFormatProvider xIFormatProvider = new CultureInfo("en-GB", true);
dsEdit.FieldValue("BDateStart", Container).ToString(xIFormatProvider,"yyyy/MM/dd")
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239
imperialz
Participant
912 Points
189 Posts
Re: Date Format (YYYY/MM/DD) From (MM/DD/YYYY)
Apr 25, 2007 11:54 AM|LINK
Hi,
U can do it using this piece of code ..
Session.LCID = proper code .. // here u have to fill the exact code which wil match for YYYY/MM/DD
Check this URL .. http://www.4guysfromrolla.com/webtech/111299-1.shtml and http://www.sql-server-helper.com/tips/date-formats.aspx
Hope this may resolve ur problem ...
Sam
Mark the post as Answered, if it helps you to fix the problem that you faced.
adam_leerox
0 Points
8 Posts
Re: Date Format (YYYY/MM/DD) From (MM/DD/YYYY)
Apr 25, 2007 10:07 PM|LINK
Thanks, I tried that and got the following error, I'm sure it's probably a simple thing but I have only just started asp.net this week, thanks.
Compiler Error Message: BC30691: 'IFormatProvider' is a type in 'System' and cannot be used as an expression.
TATWORTH
All-Star
72415 Points
14017 Posts
MVP
Re: Date Format (YYYY/MM/DD) From (MM/DD/YYYY)
Apr 25, 2007 10:48 PM|LINK
Try
CultureInfo xIFormatProvider = new CultureInfo("en-GB", true);
dsEdit.FieldValue("BDateStart", Container).ToString(xIFormatProvider,"yyyy/MM/dd");
This earns you a point and marks your thread as Resolved so we will all know you have been helped.
FAQ on the correct forum http://forums.asp.net/p/1337412/2699239.aspx#2699239