Extracting day,month,year from a datetime variable

Extracting information from datetime variable.

DateTime d = DateTime.Today;

d.Day -> Extracts the day
d.Month-> Extracts the month
d.Year -> Extracts the year

Similarly TimeOfDay,Ticks,Seconds,Minute,Millisecond,Hour,DayOfWeek,DayOfYear can also be extracted.
If you found this solution helpful or have something extra to add, feel free to share it here by commenting below.

One thought on “Extracting day,month,year from a datetime variable

Leave a Reply

Your email address will not be published. Required fields are marked *