Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  View Answers    Answer this question    Ask a question  
 

Mistery1
Nov 20, 2009, 04:19 AM
Hi there,

I know MySql is already to take YYYY-MM-DD HH:MM:SS. Therefore I need to write code to change this format when saving into MySql database from my asp.net/vb application.

I have this code that does not work. It still saves as all zeros to the database. Does anyone have any clue hot to change this format to dd-mm-yyyy in the database?

Dim dateStr As String

dateStr = DateTime.Now.Month & "-"
dateStr &= DateTime.Now.Day & "-"
dateStr &= DateTime.Now.Year & " "
dateStr &= DateTime.Now.Hour & ":"
dateStr &= DateTime.Now.Minute & ":"
dateStr &= DateTime.Now.Second &

slapshot_oi
Nov 20, 2009, 04:53 AM
You're reinventing the wheel with your function. There are routines that .Net has in place that deal with date formats: Standard DateTime Format Strings (http://msdn.microsoft.com/en-us/library/az4se3k1(VS.71).aspx). And here is a cheat sheet (http://www.nbdtech.com/Free/NetDateTimeFormatStrings.pdf).

gc69172
Nov 25, 2010, 01:47 AM
Yes you can use the toshortdate format in C#/Vb to do so. See the available options in the date format then you can do it.