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)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 洪泽县| 涞源县| 平乐县| 瑞金市| 略阳县| 秦安县| 罗甸县| 灌云县| 阿克| 平江县| 卢龙县| 旺苍县| 芦溪县| 遵义县| 徐水县| 启东市| 东方市| 大姚县| 甘谷县| 集贤县| 万年县| 定安县| 吴川市| 剑河县| 亚东县| 中方县| 罗田县| 闽清县| 二连浩特市| 冕宁县| 崇左市| 灌云县| 长白| 阿拉尔市| 息烽县| 睢宁县| 理塘县| 东城区| 汕头市| 南宫市| 舟山市|