Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   MySQL (https://www.askmehelpdesk.com/forumdisplay.php?f=442)
-   -   Date Time format (https://www.askmehelpdesk.com/showthread.php?t=417738)

  • Nov 20, 2009, 05:19 AM
    Mistery1
    Date Time format
    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 &
  • Nov 20, 2009, 05:53 AM
    slapshot_oi
    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. And here is a cheat sheet.
  • Nov 25, 2010, 02:47 AM
    gc69172
    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.

  • All times are GMT -7. The time now is 07:57 PM.