0

I want to use the date add function in this sql query I have. I tried multiple ways of formatting it, but I can't get it to work. This is one of the ways I tried it: VB.net mySQL How to use DateAdd in sql query

Below is the query I have.

sql.runquery("Select th.Thickness, odo.OptionCode
                        From FVMASTER..trackinghistory th
                        Join FVMASTER..OrderDetailOptions odo on odo.odKey=th.odKey
                        Join FVMASTER..MasterPartOptions mpo on mpo.Code=odo.OptionCode And mpo.[Group]=odo.optiongroup And mpo.QuestionKey='KGLASS' and OptionType=5
                        where th.DateTime >'"date_added = DATE_ADD(date_added,INTERVAL -4 DAY)")

This might also interest you. This is declared above the query.

 Dim dtimeStartDate As DateTime = GetWeekStartDate(tbWeek.Text, tbYear.Text)
 Dim dtimeEndDate As DateTime = DateAdd(DateInterval.Day, 7, dtimeStartDate)
9
  • 2
    Tag the question with the database you are using. Are you sure you are using MySQL? Commented Sep 3, 2021 at 11:13
  • I'm not sure what you mean by tagging the question with the database. @GordonLinoff Commented Sep 3, 2021 at 11:18
  • 2
    Add a tag for the dbms you're using. The <sql> tag is general ANSI SQL, but you're using the DATE_ADD functions, which is product specific. Commented Sep 3, 2021 at 11:31
  • You can't put a " (double quote) in the middle of a string without escaping it. A " indicates the end of the string. If you want this character as part of the string then use "". The compiler will then interpret this as a single " contained in the string. Commented Sep 3, 2021 at 16:35
  • In your previous question, you stated this is MS Sql Server. Joins normally link a primary key to a foreign key. You have put several And clauses on the second clause. These might belong in the where clause. Commented Sep 3, 2021 at 16:49

0

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.