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[
^]