Friends,
Please find my code as follows;
- objsptfsnotegen.sptfqryargs = "select CONVERT(varchar(10),DATEPART(MM,MAX(iinfill_completion)))+'/'+CONVERT(varchar(10),DATEPART(DD,MAX(iinfill_completion)))+'/'+CONVERT(varchar(10),DATEPART(YYYY,MAX(iinfill_completion))) completionyear from bg_sptfinfillingreports repa join bg_sptfAppliedArea apa on apa.pKey_applied_area_id=repa.pKey_applied_area_id where tran_id=" + hiddentranid.Value;
-
- String m_completiondate = objsptfsnotegen.GetCustomeData();
- if (m_completiondate != "")
- {
- if (!string.IsNullOrEmpty(m_completiondate))
- {
- DateTime dt1 = DateTime.Parse(m_completiondate);
- DateTime dt2 = DateTime.ParseExact("12/10/2014", "MM/dd/yyyy", CultureInfo.InvariantCulture);
- DateTime date1 = new DateTime(dt1.Year, dt1.Month, dt1.Day);
- DateTime date2 = new DateTime(dt2.Year, dt2.Month, dt2.Day);
-
- int result = DateTime.Compare(date1, date2);
-
- if (result < 0)
- objsptfsnotegen.sptfqryargs = "select top 1 CONVERT(varchar(50),Year_Announce) years,Scheme_Amount from scheme_anoncement sa join scheme_master sm on sm.Scheme_ID=sa.Scheme_ID where Scheme_Type_ID=1 and Scheme_Name='" + m_activityname + "_BG' and Year_Announce<='" + m_completiondate + "' and scheme_region='" + hiddenregion.Value + "' order by years desc";
- else if (result == 0)
- objsptfsnotegen.sptfqryargs = "select top 1 CONVERT(varchar(50),Year_Announce) years,Scheme_Amount from scheme_anoncement sa join scheme_master sm on sm.Scheme_ID=sa.Scheme_ID where Scheme_Type_ID=9 and Scheme_Name='" + m_activityname + "_BG' and Year_Announce<='" + m_completiondate + "' and scheme_region='" + hiddenregion.Value + "' order by years desc";
- else
- objsptfsnotegen.sptfqryargs = "select top 1 CONVERT(varchar(50),Year_Announce) years,Scheme_Amount from scheme_anoncement sa join scheme_master sm on sm.Scheme_ID=sa.Scheme_ID where Scheme_Type_ID=9 and Scheme_Name='" + m_activityname + "_BG' and Year_Announce<='" + m_completiondate + "' and scheme_region='" + hiddenregion.Value + "' order by years desc";
- }
The error is coming where i bold in code... Err. Name string was not recognized as a valid datetime in c#...
I had tried many ways but i can't. Please help me to fix this issue.
Thanks & Regards,