Search code examples
c#telerikformatdatetimepicker

radDateTimePicker best way to get and format the date value?


I need get the value of DateTimePicker component (like visual studio native DateTimePicker component, and basically the same thing) and turn it into a variable DateTime to execute a query in the Mysql database, the best way to play this value to see this format:

'2015-08-07'

 yyyy-mm-dd

Can anyone tell me how can I do this?


Solution

  • private DateTime InitialDate;
    private DateTime EndDate;
    
    
    this.dataInicial = new DateTime(radDateTimePickerInitialDate.Value.Year, radDateTimePickerInitialDate.Value.Month, radDateTimePickerInitialDate.Value.Day);
    this.dataFinal   = new DateTime(radDateTimePickerEndDate.Value.Year, radDateTimePickerEndDate.Value.Month, radDateTimePickerEndDate.Value.Day);