Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
OriginalGriff 9-Jun-12 0:58am    
What kind of server? File? SQL? IIS? Time server?
saeid.piran 9-Jun-12 1:06am    
sql
Sandeep Mewara 9-Jun-12 1:07am    
Please elaborate.
saeid.piran 9-Jun-12 1:11am    
i just want to create a program that shows date and time of my server.

This discussion[^] may be of some assistance to you.
 
Share this answer
 
Comments
VJ Reddy 9-Jun-12 2:47am    
Good reference. 5!
Abhinav S 9-Jun-12 2:48am    
Thanks.
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[^]
 
Share this answer
 
Comments
VJ Reddy 9-Jun-12 2:45am    
Good answer with references. 5!
Sandeep Mewara 9-Jun-12 6:41am    
Thanks VJ.
Abhinav S 9-Jun-12 2:48am    
Good points. 5.
Sandeep Mewara 9-Jun-12 6:42am    
Thanks Abhinav.
thatraja 9-Jun-12 3:16am    
5!
 
Share this answer
 
Comments
VJ Reddy 9-Jun-12 2:48am    
Good reference. 5!
Shahin Khorshidnia 9-Jun-12 2:53am    
Thank you very much :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900