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('查詢的截至時間小于一個月不能查詢!')</script>");
                          return "";
                          //Response.End();
                      }
                      return tempSql.ToString();
                  }

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

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 河南省| 高邮市| 分宜县| 陵水| 辽阳县| 京山县| 广州市| 旺苍县| 怀安县| 玉树县| 勐海县| 浏阳市| 绥芬河市| 沧州市| 新乡县| 浮梁县| 康乐县| 额尔古纳市| 秦安县| 泰州市| 常熟市| 汝州市| 从江县| 临夏市| 聂荣县| 伊宁市| 万山特区| 辽阳县| 长武县| 青铜峡市| 崇信县| 云梦县| 普洱| 格尔木市| 龙岩市| 西丰县| 荔波县| 杭州市| 嘉黎县| 上饶市| 徐水县|