如何使用不同数据类型的sql查询找到两次时间的区别? [英] How to find the difference between two time using sql query of different datatype?

查看:107
本文介绍了如何使用不同数据类型的sql查询找到两次时间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai朋友,



其实我的问题是,我必须使用查询字符串减去存储在数据库中的两个不同时间作为nvarchar。主要问题是cast转换是错误的。如何使用查询字符串减去两个不同的NVARCHAR时间值?

任何人请帮助我....如果您对问题有任何疑问请问我..

Hai friends,

Actually my problem is that,i have to subtract two different time which stored in database as nvarchar using query string. main problem is that cast convertion is error. how to subtract two different NVARCHAR values of time using query string?
Anybody please help me.... if you are having any doubts regarding question please ask me..

推荐答案

没有细节,没有直接的帮助/答案。



请使用 SearchBox [ ^ ]位于此站点的右上角。有很多例子。

请更具体,下次提供更多详细信息。它应该是:1)样本数据和2)预期输出,至少。
No details, no direct help/answer.

Please, use SearchBox[^] on the right-top corner of this site. There are tons of examples.
Please be more specific and provide more details next time. It should be: 1) sample data and 2) expected output, at least.


在处理日期时,总是建议保留Date数据类型而不是NVarchar。



无论如何你可以用转换来尝试 DATEDIFF 方法来完成它。



类似



Its always advised to keep Date datatype instead of NVarchar when handling dates.

Anyways you can try DATEDIFF method with a Convert to accomplish it.

Something like

Select DATEDIFF (MINUTE,DateColumn1,DateColumn2) from TableName;//without using Convert or Cast 


这篇关于如何使用不同数据类型的sql查询找到两次时间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆