C ++ Poco SQL查询不返回带有“介于”和“与”日期时间绑定的结果

问题描述 投票:0回答:1

我有以下代码,其中from和to作为std :: string&传递,它们是SQL db表中的日期时间,例如2019-04-10

如果我运行以下命令,则不会返回任何结果:

sql_select  << "SELECT asset, sum(amount*price) as total_cost, 
sum(amount) as total_amount FROM tradehistory_bitfinex where uid = ? 
and exchange = ? and time between ?  and ?   group by asset",
                 Poco::Data::Keywords::into(portfolio),
                 Poco::Data::Keywords::bind(uid),
                 Poco::Data::Keywords::bind(exchange);
                 //Poco::Data::Keywords::bind(from),
                 //Poco::Data::Keywords::bind(to);

如果我运行以下命令,它将正确返回结果:

sql_select  << "SELECT asset, sum(amount*price) as total_cost, 
sum(amount) as total_amount FROM tradehistory_bitfinex where uid = ? 
and exchange = ? and time between '2019-04-10'  and '2019-04-10'   
group by asset",
                 Poco::Data::Keywords::into(portfolio),
                 Poco::Data::Keywords::bind(uid),
                 Poco::Data::Keywords::bind(exchange);
                 //Poco::Data::Keywords::bind(from),
                 //Poco::Data::Keywords::bind(to);

日期时间/字符串绑定似乎有问题。

谢谢。

c++ poco-libraries
1个回答
0
投票

GoQuestion:

© www.soinside.com 2019 - 2024. All rights reserved.