日期:2014-05-17 浏览次数:20770 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
namespace ConsoleApplication1
{
class Program
{
static int getMonth1(DateTime date1, DateTime date2)
{
int year1 = date1.Year;
int year2 = date2.Year;
int month1 = date1.Month;
int month2 = date2.Month;
int a=year2-year1;
int months;
if (a == 0)
{
months = month2 - month1;
}
else
{
months = month2;
}
return months;
}
static string mysql (string date1)
{
DateTime starttime=Convert.ToDateTime(date1);
DateTime endtime=DateTime.Now;
string sql = "select * from zy_bhjfyz" + Convert.ToString(starttime.Year) + starttime.Month.ToString("D2");
int m,i;
m = getMonth1(starttime, endtime);
if (endtime.Year - starttime.Year == 0)
{
for (i = 1; i <= m; i++)
{
sql = sql + "union all " + "select * from zy_bhjfyz" + Convert.ToString(starttime.Year) + starttime.AddMonths(i).Month.ToString("D2");