Problem to the script

Here is the error
 
You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near '%m-%d %H:%i:%s') as in_ti
me_dscr,  date_format(p.stockout_time,'%Y-%m-%d %H:%i:%' at line 1
 

Open in new window

got within VS, while this is the script
 
                sql = @"select " +
                    " null as row_num, " +
                    " date_format(p.in_time,'%Y-%m-%d %H:%i:%s') as in_time_dscr, " +
                    " date_format(p.stockout_time,'%Y-%m-%d %H:%i:%s') as stockout_time_dscr, " +
                    " date_format(ADDDATE(p.store_rcv_time, " + package_expiry_day_vg.ToString() + "), '%c月%e日') as expiry_date_chi, " +
                    " date_format(ADDDATE(p.store_rcv_time, " + package_expiry_day_vg.ToString() + "), '%D %b') as expiry_date_eng, " +
                    " c_s.sms_addr_eng, " +
                    " c_s.sms_addr_chi, " +
                    " c_s.store_no, " +
                    " p.*  " +
                    " from package_vg p  " +
                    " left join c_store_vg c_s on c_s.dscr = p.store_dscr " +
                    " where p.deleted = '0' " +
                    " and (p.phone like '9%' or p.phone like '6%' or p.phone like '5%') " +
                    " and length(trim(p.phone)) = 8 " +
                    " and c_s.send_sms = 1 " +
                    " and (p.status = 'store_rcv' or p.status = 'store_app_rtn') " +
                    " and p.sms_send = 0 " +
                    " and date_format(p.store_rcv_time,'%Y-%m-%d') >= " + DBUtil.GetSqlString(From_Date.ToString(DBUtil.DATE_FORMAT)) + " " +
                    " and date_format(p.store_rcv_time,'%Y-%m-%d') < " + DBUtil.GetSqlString(To_Date.ToString(DBUtil.DATETIME_FORMAT)) + " " +
                    " order by p.id";
					

Open in new window

why?
LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
Why do you compare strings in the first place? This leads normally to a table scan. Also use a parameterized query, not a manually crafted SQL string.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HuaMin ChenProblem resolverAuthor Commented:
Sorry, but why do I get the problem mentioned?
ste5anSenior DeveloperCommented:
Use line breaks to get a better line number..

Also output the string and before executing in and run it in the workbench.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.