0

I'm getting an error when the form load and it said FUNCTION databasename.DateAdd does 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()
1
  • 2
    Check MySQL's Date_add() function Commented Feb 8, 2016 at 5:23

2 Answers 2

1

You've used VB.NET's DateAdd() inside the query which won't work for MySQL because MySQL doesn't has an inbuilt function like that

Syntax for MySQL date add function is 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)"
Sign up to request clarification or add additional context in comments.

Comments

1

You can do something like below-

ADDDATE(date_column, INTERVAL 4 YEAR)
ADDDATE(date_column, INTERVAL 4 MONTH)
ADDDATE(date_column, INTERVAL 4 DAY)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.