易截截图软件、单文件、免安装、纯绿色、仅160KB

Access 中比较时间sql语句如何实现

Access中存储的时间跟当前时间比较,
数据库中时间格式:2005-7-5 15:23:35
select * from table1 where dateField < now()

普通比较,就是这样,如果要计算天,月,年,甚至小时,分钟的,差额。

就要用到datediff(,,,)

类似这样:
select * from EventLog where theTime>=#2009-12-17 11:20:35# and ...(其中theTime为数据库中的时间)

如果是datetime类型的那么你用
CString strsql;
CString strcurtime; // 格式应该是 2009-12-17 11:23:30
strsql.Format("select * from 表名 where where 列名 < ('%s.999')",strcurtime);


SQL code:
SELECT * from 表名 WHERE 列名 < now()


//或者在程序中先获取当前时间,传入SQL语句

C/C++ code:
CString str;
COleDateTime tm;
tm = COleDateTime::GetCurrentTime();
str = tm.Format("%Y-%m-%d %H:%M:%S");
str.Format("SELECT * from 表名 WHERE 列名 < '%s'", str);


我就是不想再获取时间,想直接通过sql来比较
比如:SELECT * from 表名 WHERE  列名 < now()
不知道now()得到的时间是什么格式的,有没有精确到秒

应该可以直接比较的啊,now是datatime类型,默认是精确到秒的


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

sql 截取字符串

我要得到一个字符串如:
sdfk|||sgts
sdfsfd|||rgreg
wrfw|||sefw
就是要得到|||后面的字符串,有什么函数吗?怎么用呢?谢谢!
SQL code:
select
right(col,len(col)-charindex('|||',col)-2)
f ......

sql 存储过程

我要做一个定点事件,是每天晚上12点就把三个表里的信息放入一个表里,我想用存储过程来写,怎么写呢?,那位高手帮帮忙吧,非常感谢!

用户名是唯一的
表A  字段
用户名:Name  ,邮箱:Ema ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号