从服务器获取日期和时间 [英] get date and time from server
本文介绍了从服务器获取日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取服务器的日期和时间并将其放入一些变量中?
服务器ip:192.168.1.1(Windows 2003 Server)
变量:
年-月-日
小时-分钟-秒
How can i get date and time of a server and put it into some variables ?
server ip : 192.168.1.1 (windows 2003 server)
variables :
Year - Month - Day
Hour - Minute - Second
推荐答案
^ ]
步骤:
1.使用ADO.NET与SQL Server通讯.
2.与服务器对话-使用查询获取数据-此处的当前日期时间
3.使用 MSDN:GETDATE(Transact-SQL) [ MSDN:DateTime结构 [ SQL SERVER –检索SQL Server中的当前日期时间 [使用ADO.NET访问数据 [ ^ ]
Steps:
1. Use ADO.NET to talk to SQL Server.
2. Talk to server - Use query to get data - current datetime here
3. Use MSDN: GETDATE (Transact-SQL)[^] as per your need
4. Once you get the data back, parse the date as per your need into small parts to use. Use MSDN: DateTime Structure[^] to parse it into smaller parts like year, month, day, hour, etc.
This blog entry will be a good read on getting current datetime from server: SQL SERVER – Retrieve Current Date Time in SQL Server[^]
For ADO.NET: Accessing data with ADO.NET[^]
讨论 [
This discussion[^] may be of some assistance to you.
这篇关于从服务器获取日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文