This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / 新手求问SQL问题, 谢谢!我的LINUX 装入Lucid 数据库, There is a column in a table in the database. This column is "datetime" but its type is "char" instead of "Date". This "datetime" has the following format:
" [10/Jun/2008:07:41:39 -0700] "
Now I want to use SQL to query all those records that have a timedate difference of 30 minutes, or 60 minutes, or 6 hours, or even one day comparing to the current time. 如何写SQL?
非常感谢!
-mynewproject222(mynewproject222);
2008-6-20
{426}
(#4512051@0)
-
不知道lucid. 你不能把char转换成时间吗?select * from table where to_date([datetime]) >xxx and to_date ( [datetime])<yyy
-holdon(again);
2008-6-20
(#4512137@0)
-
In order to use CAST or CONVERT function to convert your char variable to datetime, you need format the char variable first.For example
10/Jun/2008:07:41:39-0700 should be 10/Jun/2008 07:41:39:070.
-deep_blue(BLUE);
2008-6-20
{75}
(#4512178@0)
-
感谢楼上两位大虾.
-mynewproject222(mynewproject222);
2008-6-21
(#4515685@0)