Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
string mac_rate_eff_date = DateTime.Now.ToString("yy-M-dd");
       string FromDate = "";
       if (tabname == "ItemOfMachinery")
       {
           if (dbwork == "Insert")
           {
               imacc_id = int.Parse(drpcategoryofmachinery.SelectedValue);
               mac_code = txtcode.Text;
               ma_short_desc = txtshort.Text;
               mac_long_desc = txtDescription.Text;
               mac_unit = int.Parse(drpUnit.SelectedItem.Value);
               mac_rate = double.Parse(drpcategoryofmachinery.SelectedValue);
               FromDate = txteffdate.Text;

               string[] datesplit = FromDate.Split('-');
               mac_rate_eff_date = datesplit[2] + "-" + datesplit[1] + "-" + datesplit[0];

               if (datesplit[0].Length == 4)
               {
                   mac_rate_eff_date = datesplit[0] + "-" + datesplit[1] + "-" + datesplit[2];
               }
           }
           else
           {
               mac_id = int.Parse(hdnmac_id.Value);
               mac_rate_id = int.Parse(hdnmac_rate_id.Value);
               imacc_id = int.Parse(drpcategoryofmachinery.SelectedValue);
               ma_short_desc = hdnshortdesc.Value;
               mac_long_desc = hdnlongdesc.Value;
               mac_unit = 0;
               mac_rate =double.Parse(hdnrate.Value);
               FromDate = hdnmac_effdate.Value;
               string[] datesplit = FromDate.Split('-');
               mac_rate_eff_date = datesplit[2] + "-" + datesplit[1] + "-" + datesplit[0];

               //if(datesplit[0].Length==4)
               //{
               //    mac_rate_eff_date = datesplit[0] + "-" + datesplit[1] + "-" + datesplit[2];
               //}

           }
           if (tabname == "ItemOfMachinery")
           {
               if (dbwork == "delete")
               {
                   mac_id = Convert.ToInt32(hdnmac_id.Value);
                   mac_rate_id = int.Parse(hdnmac_rate_id.Value);
               }
               else
               {
                   //imc_id = int.Parse(hdnworkid.Value);
                   //icode = hdncategorycode.Value;
                   //icatname = hdncategoryname.Value;
               }
           }
Posted
Updated 29-Dec-14 23:50pm
v2
Comments
abhishek_singh 30-Dec-14 6:05am    
please be specify a particular line where you find that error, also provide more information like actual data which are going to convert on multiple spaces.

1 solution

I think your datetime format is not correct. Please make it as supported format like

C#
ToString("yyyy/MM/dd")
or

see the link below
http://www.csharp-examples.net/string-format-datetime/[^]

If the error is not occur on your first line then be specific about which line error occurred ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900