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 閱讀(114) 評論(0)  編輯  收藏

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


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 临湘市| 内江市| 永顺县| 阿巴嘎旗| 天气| 忻城县| 冀州市| 阆中市| 疏勒县| 黑河市| 隆尧县| 芦溪县| 若尔盖县| 邯郸县| 仪征市| 阳谷县| 仁化县| 美姑县| 兴业县| 攀枝花市| 盈江县| 安平县| 白水县| 金溪县| 澳门| 裕民县| 清水河县| 久治县| 龙山县| 南京市| 翁牛特旗| 保山市| 乌拉特前旗| 霍林郭勒市| 沐川县| 隆子县| 清原| 绥棱县| 集贤县| 湖北省| 北海市|