C#中如何提取datetimepicker的年

2024-12-05 01:37:26
推荐回答(3个)
回答1:

Convert.ToInt32(datetimepicker.value.tostring("yyyy");//年
Convert.ToInt32(datetimepicker.value.tostring("yyyy-MM-dd");//年月日
Convert.ToInt32(datetimepicker.value.tostring("MM");//月
Convert.ToInt32(datetimepicker.value.tostring("dd");//日

回答2:

int a = this.dateTimePicker1.Value.Year;

回答3:

this.dateTimePicker1.Value.Year