public static string StructSql(int startYear, int startMonth, int endYear, int endMonth)
                  {
                      StringBuilder tempSql = new StringBuilder();
                      DateTime dtStart = new DateTime(startYear, startMonth, 1);
                      DateTime dtEnd = new DateTime(endYear, endMonth, 1);
                      TimeSpan ts = dtEnd - dtStart;
                      int tempStartYear = startYear;
                      int tempStartMonth = startMonth;
                      if (ts.TotalDays > 25)
                      {

                          for (int i = startMonth; i <= 12; i++)
                          {
                              if (i == startMonth && tempStartYear == startYear)
                                  tempSql.AppendFormat("select '{0}' as A,'{1}' as B from dual\n", tempStartYear.ToString(), tempStartMonth.ToString());
                              else
                                  tempSql.AppendFormat(" union all select '{0}' as A,'{1}' as B from dual\n", tempStartYear.ToString(), tempStartMonth.ToString());


                           
                              if (tempStartYear >= endYear && tempStartMonth >= endMonth)
                                  break;

                              if (i == 12)
                              {
                                  tempStartYear++;
                                  i = 0;
                                  tempStartMonth = 0;

                              }

                              tempStartMonth++;
                           
                          }
                      }
                      else
                      {
                         // Page.RegisterStartupScript("message", "<script type='text/javascript'>alert('查詢(xún)的截至?xí)r間小于一個(gè)月不能查詢(xún)!')</script>");
                          return "";
                          //Response.End();
                      }
                      return tempSql.ToString();
                  }

          posted on 2010-09-03 16:19 sanmao 閱讀(114) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          常用鏈接

          留言簿(5)

          隨筆分類(lèi)

          隨筆檔案

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 叶城县| 安乡县| 邢台县| 旬阳县| 邓州市| 天峨县| 汶上县| 吉隆县| 襄汾县| 天全县| 新竹市| 宜君县| 九江市| 上饶县| 香港| 麻阳| 广安市| 化德县| 威远县| 共和县| 乌苏市| 永城市| 中牟县| 安国市| 丰城市| 砀山县| 城口县| 阿图什市| 濉溪县| 马龙县| 博客| 教育| 彰化市| 尼木县| 略阳县| 迭部县| 施甸县| 天柱县| 鄂伦春自治旗| 霍邱县| 洪江市|