none
save date to mysql database

    Question

  • front end: vb.net

    backend: mysql

    Hello Community,

    I am trying to save a date to a mysql database and usually the only format permited to be saved in the table is YYYY-MM-DD

    On the form the datetime picker is formated like this MM-DD-YYYY

    The thing is i am using dataset created by wizard to save the data, what should i do to be able to format this for save and read because it is giving me errors.

    Thanks in advance,

    Best Regards.

    Tuesday, September 07, 2010 6:39 PM

Answers

  • Hi,

    try this one:

    INSERT INTO inventory
       (NAME, Address, Phone, Vin_No, TYPE, Category, YEAR, 
        Make, Model, Style_Name, Engine_Size, Fuel_Type, Cylinder, 
        Transmission, Body_Style, Drive_Train, Color,
        Title_No, Date_In, Miles_In, Mileage_Unknown, Beyond_Mechanical, Initial_Cost, Work_Parts_Cost, Auction_Fee, Warehouse, Branch, `User`)
    VALUES 
        ('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
         'a', 'a', 'a', 'a', DATE_FORMAT('12/12/2008', '%Y%m%d'),
         'a', 1, 1, '100','a', 'a', 'a', 'a', 'a')
    
    

    Hannes

    If you have got questions about this, just ask.
    Mark the thread as answered if the answer helps you. This helps others who have the same problem !
    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    Wednesday, September 08, 2010 3:35 PM

All replies

  • Have you tried using the DATE_FORMAT function in MySQL?

    http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format

     


    Paul ~~~~ Microsoft MVP (Visual Basic)
    Tuesday, September 07, 2010 7:39 PM
  • yes but the problem i am using dataset created by wizard, where should i use that?
    Tuesday, September 07, 2010 7:40 PM
  • If I understand you question, can't you change your query using the Dataset Designer?

    Paul ~~~~ Microsoft MVP (Visual Basic)
    Tuesday, September 07, 2010 7:46 PM
  • INSERT INTO inventory
                 (NAME, Address, Phone, Vin_No, TYPE, Category, YEAR, Make, Model, Style_Name, Engine_Size, Fuel_Type, Cylinder, Transmission, Body_Style, Drive_Train, Color,
                 Title_No, Date_In, Miles_In, Mileage_Unknown, Beyond_Mechanical, Initial_Cost, Work_Parts_Cost, Auction_Fee, Warehouse, Branch, `User`)
    VALUES    ('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
                 'a', 'a', 'a', 'a', DATE_FORMAT('12/12/2008', '%Y-%m-%d'), 'a', 1, 1, '100',
                 'a', 'a', 'a', 'a', 'a')
    

    it doesn't work..
    Tuesday, September 07, 2010 8:28 PM
  • No mention of exception messages. Could you be a bit more specific when you say "doesn't work"?
    Paul ~~~~ Microsoft MVP (Visual Basic)
    Wednesday, September 08, 2010 1:30 AM
  • 
    

    it doesn't work..
    Did you plug in the power of your computer?
    Success
    Cor
    Wednesday, September 08, 2010 7:44 AM
  • i have a laptop, it can run on battery :P
    Wednesday, September 08, 2010 2:27 PM
  • No mention of exception messages. Could you be a bit more specific when you say "doesn't work"?
    Paul ~~~~ Microsoft MVP (Visual Basic)

    Paul, the thing is, it doesn't raise any error, it just inserts a blank date...
    Wednesday, September 08, 2010 2:28 PM
  • Hi,

    try this one:

    INSERT INTO inventory
       (NAME, Address, Phone, Vin_No, TYPE, Category, YEAR, 
        Make, Model, Style_Name, Engine_Size, Fuel_Type, Cylinder, 
        Transmission, Body_Style, Drive_Train, Color,
        Title_No, Date_In, Miles_In, Mileage_Unknown, Beyond_Mechanical, Initial_Cost, Work_Parts_Cost, Auction_Fee, Warehouse, Branch, `User`)
    VALUES 
        ('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
         'a', 'a', 'a', 'a', DATE_FORMAT('12/12/2008', '%Y%m%d'),
         'a', 1, 1, '100','a', 'a', 'a', 'a', 'a')
    
    

    Hannes

    If you have got questions about this, just ask.
    Mark the thread as answered if the answer helps you. This helps others who have the same problem !
    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    Wednesday, September 08, 2010 3:35 PM
  • No mention of exception messages. Could you be a bit more specific when you say "doesn't work"?
    Paul ~~~~ Microsoft MVP (Visual Basic)

    Paul, the thing is, it doesn't raise any error, it just inserts a blank date...
    Shouldn't the format of your date value be year, month, day and not month, day, year?

    Paul ~~~~ Microsoft MVP (Visual Basic)
    Wednesday, September 08, 2010 5:33 PM