作者:蓝社 | 来源:互联网 | 2023-05-19 08:48
txtdate=DateTime.Parse(Context.Request["txtDate"].ToString()).ToString("yyyy-MM-dd");
//类调用:
string cOnnectionString= ConfigurationManager.ConnectionStrings["DefaultDbServerConnection"].ConnectionString;
sql语句按日期查询
select * from History where convert(varchar(10),STime,120)='2011-12-01'
select * from History where datediff(dd,STime,'2011-12-01')=0
select * from History where STime>='2011-12-1 00:00:00.000' and STime<='2011-12-1 23:59:59.997'
//最近新接触可空类型,工作中写了这么一个对象类,其中有一个属性字段是这样子的
///
/// 取样日期时间
///
private DateTime? samdate;
public DateTime? SamDate
{
get { return samdate; }
set { samdate = value; }
}
//最终在UI层赋值后,显示时,一直不出现,最终原因原来是
//DateTime?为可空,如果不空,得先转换为string,然后将string转换为DateTime,在将DateTime转换为你想要的格式的string串,
//感觉非常麻烦,具体方法如下
string strdate = DateTime.Parse(modSamVouch.SamDate.ToString()).ToString("yyyy-MM-dd")
//亦或者我的方法
string strdate=SamDate==null?"":DateTime.Parse(SamDate).ToString("yyyy-MM-dd")
Aspose.Cells.dll使用:
public static DataTable ExeclToDataTable(string Path)
{
try
{
DataTable dt = new DataTable();
Aspose.Cells.Workbook workbook = new Workbook();
workbook.Open(Path);
Worksheets wsts = workbook.Worksheets;
for (int i = 0; i {
Worksheet wst = wsts[i];
int MaxR = wst.Cells.MaxRow;
int MaxC = wst.Cells.MaxColumn;
if (MaxR > 0 && MaxC > 0)
{
dt = wst.Cells.ExportDataTableAsString(0, 0, MaxR + 1, MaxC + 1, true);
}
}
return dt;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
在SQLSERVER中批量替换字符串的方法:
update ProgInfo set JoinTime=replace(JoinTime,'2007-3-2','2007-03-02')