如何从数据库所在的服务器计算机中提取日期和时间 [英] How Do I Extract Date And Time From Server Computer Where Database Resides

查看:179
本文介绍了如何从数据库所在的服务器计算机中提取日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个系统,在当前日期和时间从数据库所在的服务器(以及发布应用程序)中提取..我不想使用system.datetime.now,因为它返回我的客户端计算机日期时间哪个不可靠..如何从服务器机器中提取日期和时间并在我的.net应用程序中使用它?任何帮助..

i have a system where in current date and time is to be extracted from server where database resides(and where application is published) .. I do not want to use system.datetime.now because it returns me client computer date time which is not reliable.. how can i extract date and time from server machine and use it in my .net application??? any help..

推荐答案

如果您的数据库在服务器中,那么在Oracle中选择sysdate中的一个查询

>
在sql中使用getdate()







在你的appplication

system.datetime.now总是返回服务器时间.....
if your Database is in Server then write a query
in Oracle 'select sysdate from dual'
in sql use getdate()



in your appplication
system.datetime.now always returns the server time .....


示例SP:不使用变量



CREATE PROCEDURE dbo.SPNameHere



AS

BEGIN

SELECT GETDATE()AS CurrentDateTime



END
sample SP :not using variable

CREATE PROCEDURE dbo.SPNameHere

AS
BEGIN
SELECT GETDATE() AS CurrentDateTime

END


这篇关于如何从数据库所在的服务器计算机中提取日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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