Reputation: 23
How i can get only Date with datetime datatype from DateTimePicker.CustomFormat("dd");
datetimepicker1.CustomFormat = "dd";
it gives me full date but i need onlye Day on month like 05 I am also Storing the datetimepicker value in the database and the database column have datetime datatype
Upvotes: 0
Views: 165
Reputation: 26209
Problem : you have set only the CustomFormat
Property of the DateTimePicker
control without Changing the Format
of the DateTimePicker
control to Custom
.
Solution : You need to set Format
of the DateTimePicker
control to Custom
Try This:
datetimepicker1.Format = DateTimePickerFormat.Custom;
datetimepicker1.CustomFormat = "dd";
Solution 2: if you want to get only Date
part from the Selected Date value you can use Day
property of DateTimePicker.
Try This:
int day=dateTimePicker1.Value.Day;
Upvotes: 1