VB.net mySQL How to use DateAdd in sql query -
i'm getting error when form load , said function databasename.dateadd not exist
con.open() cmd.connection = con cmd.commandtext = "update pawn set status = 'renewed', date_added = dateadd(month,4,date_added), first_date = dateadd(month,5,first_date), second_date = dateadd(month,6,second_date), due_date = dateadd(month,7,due_date)" dr = cmd.executereader con.close()
you've used vb.net's dateadd() inside query won't work mysql because mysql doesn't has inbuilt function
syntax mysql date add function date_add(date,interval expr type)
cmd.commandtext = "update pawn set status = 'renewed' " & _ ",date_added = date_add(date_added,interval 4 month)" & _ ",first_date = date_add(first_date,interval 5 month)" & _ ",second_date = date_add(second_date,interval 6 month)" & _ ",due_date = date_add(due_date,interval 7 month)"
Comments
Post a Comment