如何从数据库所在的服务器计算机中提取日期和时间
问题描述:
我有一个系统,在当前日期和时间从数据库所在的服务器(以及发布应用程序)中提取..我不想使用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