在 Toad for MySQL 中执行 SELECT 语句时出现错误

发布于 2024-10-19 07:26:00 字数 205 浏览 7 评论 0原文

当我尝试在 Toad 中执行简单的 SELECT 语句时,出现此错误

 MySql.Data.Types.MySqlConversionException
 Unable to convert MySQL date/time value to System.DateTime

可能出了什么问题?

I am getting this error while I am trying to execute a simple SELECT statement in Toad

 MySql.Data.Types.MySqlConversionException
 Unable to convert MySQL date/time value to System.DateTime

What could be wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

楠木可依 2024-10-26 07:26:00

这可能意味着以下两个常见问题之一:

1) 零日期,即 MySQL 中的 0000-00-00。 MySQL允许您存储它们来标记0日期,您甚至可以使用0001-01-01,但并非所有驱动程序或下游程序都可以处理它们。添加到连接字符串

Allow Zero Datetime=true;

另一种选择是显式删除它们,例如

SELECT IF(DateCol='0000-00-00' OR DateCol<'1970-01-01', NULL, DateCol) as DateCol,
      Othercol1, ID ....
FROM TBL

2) 日期格式。对于某些驱动程序/程序组合,日期作为字符串处理。显式转换是必要的:

SELECT DATE_FORMAT(DateCol, '%m/%d/%Y') as DateCol,
      Othercol1, ID ....
FROM TBL

That could mean one of these two common issues:

1) Zero dates, which are 0000-00-00 in MySQL. MySQL allows you to store them to mark 0 dates, you can even use 0001-01-01, but not all drivers or downstream programs can handle them. Add to the connection string

Allow Zero Datetime=true;

The other choice is explicitly removing them, something like

SELECT IF(DateCol='0000-00-00' OR DateCol<'1970-01-01', NULL, DateCol) as DateCol,
      Othercol1, ID ....
FROM TBL

2) Date formatting. For some driver/program combination, the dates are handled as strings. Explicit conversion is necessary:

SELECT DATE_FORMAT(DateCol, '%m/%d/%Y') as DateCol,
      Othercol1, ID ....
FROM TBL
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文