-1

I have a dateTimePicker1 in my form and it display the time with hour and seconds but i just need to display just the day like 27/11/2014 00:00:00 And this is my code

DateTime dt1 = dateTimePicker1.Value;
DateTime d1 = Convert.ToDateTime(dt1); 
razzek
  • 599
  • 6
  • 23
  • 3
    Here is what you need: http://stackoverflow.com/questions/6121271/how-to-remove-time-portion-of-date-in-c-sharp-in-datetime-object-only – SergioR Nov 27 '14 at 18:00
  • Did you try to use search first? – Fedor Nov 27 '14 at 18:02
  • `DateTimePicker.Value` is already a `DateTime` why you need to convert it ? Its not clear what you exactly need? do you need the Date portion or you only want to show Date with no time in your control. – Habib Nov 27 '14 at 18:02
  • If you're only needing to display the day, why are you including an empty timestamp? Makes no sense. – Drew Kennedy Nov 27 '14 at 18:04

3 Answers3

2
 d1.Date.ToString("dd/MM/yyyy hh:mm:ss");
JamesDill
  • 1,709
  • 16
  • 22
2
DateTime d1 = dt1.Date;

gives you only the date potion

overflowed
  • 1,613
  • 8
  • 13
1

go to your dateTimePicker1's properties and select Custom for Format option. than go to Custom Format option and dd/MM/yyyy hh:mm:ss. You can make your own format from here and if u look at form before ask u could find here or here

Community
  • 1
  • 1
Hakan Saglam
  • 191
  • 1
  • 6