MS sql查询找到两次之间的差异?

时间:2013-04-26 09:33:15

标签: asp.net sql-server-2005

我有一个名为'student_details'的数据库表。它包含一个coloumn -'token_timestamp'。我想找出当前时间和'token_timestamp'之间的区别。它不应该大于80分钟。我应该在'哪里'条件下写什么?请帮忙

    SqlCommand cmd=new SqlCommand("select student_id from student_details where  ??? ,con1);

1 个答案:

答案 0 :(得分:0)

试试这个......

 SqlCommand cmd=new SqlCommand("select student_id from student_details where 
    DateDiff(minute,Cast(token_timestamp as smalldatetime),CAST(cast(GetDate() as time) as smalldatetime))>80"
    ,con1);