hi I am using mysql as a database it will accept date format like this (yyyy-mm-dd) when the user enter in the text box in any format it will accept only format listed above. I have tried this one by using below code
string dob = tbDob.Text;
DateTime dv = DateTime.Parse(dob);
string format = dv.ToString("yyyy-mm-dd");
but it will showing the month as zero
input :19-08-1908
output:1908-00-19
would any one solve this pls...
mm
is for minutes; MM
is for month.
Try dv.ToString("yyyy-MM-dd")
If that's not the format you had in mind, try:
M
: Numeric month (no leading zero)MM
: Numeric month (with leading zero)MMM
: Abbreviated month name (e.g., "Jan")MMMM
: Full month name (e.g., "January")You are formatting the string according to "yyyy-mm-dd". But you are giving input in the format
input :19-08-1908
so it taking year as 1908, ie its combining 19 and 08 and its taking month as 00 and date as 19 (19 out of 1908).
Change the input format to yyyy-mm-dd, instead, to get the correct output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With