C# Sharp Exercises: Demonstrate the Day property
C# Sharp DateTime: Exercise-2 with Solution
Write a C# Sharp program to display the Day properties (year, month, day, hour, minute, second, millisecond etc.)
Sample Solution:-
C# Sharp Code:
using System;
public class Example2
{
public static void Main()
{
System.DateTime moment = new System.DateTime(2016, 8, 16, 3, 57, 32, 11);
Console.WriteLine("year = " +moment.Year);
Console.WriteLine("month = " +moment.Month);
Console.WriteLine("day = " +moment.Day);
Console.WriteLine("hour = " +moment.Hour);
Console.WriteLine("minute = " +moment.Minute);
Console.WriteLine("second = " +moment.Second);
Console.WriteLine("millisecond = " +moment.Millisecond);
}
}
Sample Output:
year = 2016 month = 8 day = 16 hour = 3 minute = 57 second = 32 millisecond = 11
Flowchart :

C# Sharp Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a C# Sharp program to extract the Date property and display the DateTime value in the formatted output.
Next: Write a C# Sharp program to get the day of the week for a specified date.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Exercises: Weekly Top 12 Most Popular Topics
- Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools
- JavaScript: HTML Form Validation
- SQL Exercises, Practice, Solution - SUBQUERIES
- C Programming Exercises, Practice, Solution : For Loop
- Python Exercises, Practice, Solution
- Python Data Type: List - Exercises, Practice, Solution
- C++ Basic: Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - exercises on Employee Database
- SQL Exercises, Practice, Solution - exercises on Movie Database
- SQL Exercises, Practice, Solution - exercises on Soccer Database
- C Programming Exercises, Practice, Solution : Recursion