sql 常用语句和技巧收集中,会不断新增
1.只返回年月日(去掉时分秒),pDate是时间列名
querystring = "select pName,pNum,convert(varchar(10),pDate,120),pType,pNote,pTime,pUser,ID from INFO order by pDate desc"
2.只返回年或月等,用DATEPART函数
querystring = "select pName,pNum,convert(varchar(10),pDate,120),pType,pNote,pTime,pUser,ID from INFO where DATEPART(yyyy,pDate)='" & tYear & "' and DATEPART(MM,pDate)='" & tMonth & "' order by pDate desc"