We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Converting the data/date to Mysql/string format

Hello,

i have the following 

SfDateTimeEdit 
DateTimeEditingMode = Mask
DateTimePatter = Custom
Format = dd/MM/yyyy H:mm

i am trying to convert to Mysql readable yyyy-mm-dd hh:mm:ss

but it doesnt allow me to get the correct time when converting

the code i have is 
Dim date As String = Convert.ToDateTime(SfDateTimeEdit3.Value).ToString("yyyy-MM-dd H:mm:ss")

it converts fine if the editing mode is default but i then cannot rely on the user putting the : between causing it to default to 00:00

Any help on this matter would be fantastic. 



3 Replies

AA Arulraj A Syncfusion Team December 12, 2018 08:46 AM UTC

Hi Matt, 

Thanks for using Syncfusion product. 

We have analyzed your requirement. In SfDateTimeEdit control, we need to set the Value as DateTime.Now for showing the current DateTime in the Custom DateTimePattern. Please make use of the below code snippet. 

C# 
this.sfDateTimeEdit.DateTimeEditingMode = Syncfusion.WinForms.Input.Enums.DateTimeEditingMode.Mask; 
this.sfDateTimeEdit.DateTimePattern = Syncfusion.WinForms.Input.Enums.DateTimePattern.Custom; 
this.sfDateTimeEdit.Format = "dd/MM/yyyy hh:mm:ss"; 
 
this.sfDateTimeEdit.Value = DateTime.Now; 
 

Please make use of the below screenshot for your reference. 
 
Screenshot 

 

Please check the above solution and let us know if it is helpful. 

Arulraj A 



MA Matt December 12, 2018 09:04 AM UTC

Hello,

Thank you.

i in the meantime worked out the issue.

it was because allow Null was True.

once i had switched to False it worked with the original code. 


AA Arulraj A Syncfusion Team December 12, 2018 09:34 AM UTC

Hi Matt,

Thanks for the update.

We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you.


Regards,
Arulraj A

Loader.
Live Chat Icon For mobile
Up arrow icon