会话日期时间值 [英] session datetime value

查看:75
本文介绍了会话日期时间值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在table.now中存储了login_time和logout_time。我必须存储logout_time-login_time intable的差异。我可以做什么。我试过以下但是我不能做...



i have store login_time and logout_time in table.now i have to store difference of logout_time-login_time intable.what i can do.i have try following but i can''t do...

SqlCommand cmd3 = new SqlCommand("update logininfo set totaltime=logouttime-logintime where log_id=" + logid, cnn);

推荐答案

为什么?

为什么要存储你已经存在的东西,从某种意义上说你可以随时计算它吗?将它作为单独的信息存储只会增加数据库大小,并提供错误进入的路径 - 就像它一样 - 当In和Out时间之间的差异以及商店值不匹配时。



Why?
Why store something that you have already, in the sense that you can calculate it whenever you need to? Storing it as separate information just increases your database size and provides a route for error to creep in - as it does - when somehow the difference between the In and Out times, and the stores value do not match.

SELECT DATEDIFF(second, logintime, logouttime) as loggedInSeconds FROM logininfo





如果你真的必须存储它,然后你可以使用相同的命令:





If you really must store it, then you can use the same command:

UPDATE logininfo SET totaltime=DATEDIFF(second, logintime, logouttime)





但我我自己也不会这样做。



But I wouldn''t do it myself.


这篇关于会话日期时间值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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