Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i working on student registration system , i need to sort my registered students with joined year so .

how do i get year from datetimepicker ?
Posted

Or if you want to leave the datepicker as a datepicker and just get hold of the year then use
int myYear = dateTimePicker1.Value.Year;
 
Share this answer
 
hi,

give this coding in your form load event.


C#
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "yyyy";



while getting value of datetimepicker1, it returns year only.



regards,
Prakash.T
 
Share this answer
 

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