易截截图软件、单文件、免安装、纯绿色、仅160KB

java时间函数,以及 sql 时间范围查找 代码

 String keyword = request.getParameter("keyword");
   String timeRange = request.getParameter("timeRange");
   String type = request.getParameter("type");
  
   StringBuffer sql = new StringBuffer();
   sql.append("use webstation_leadall select f.id,f.title,f.publishtime from information f left join infotype t on f.typeid=t.id  where ");
   if( (keyword == null)|| (keyword.equals("")) ){  
   sql.append("title like '%' and ");
  }else {
   sql.append("title like '%"+keyword +"%' and ");
  }
  
  if(timeRange.equals("")||timeRange==null){
   sql.append("");
  }else{
   //Calendar cal = Calendar.getInstance();
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
      //String now = sdf.format(cal.getTime());
   String begintime = "";
   String endtime = "";
   java.util.Date myDate=new java.util.Date();
   long myTime = 0;
   if(timeRange.equals("1")){
    myTime=((myDate.getTime()/1000)-60*60*24)*1000;
    begintime = sdf.format(new   java.util.Date(myTime));
    endtime = sdf.format(myDate);
    //System.out.println("------"+begintime+"+++++"+endtime);
   }else if(timeRange.equals("3")){
    myTime=((myDate.getTime()/1000)-60*60*24*3)*1000;
    begintime = sdf.format(new   java.util.Date(myTime));
    endtime = sdf.format(myDate);
    //System.out.println("------"+begintime+"+++++"+endtime);
   }else if(timeRange.equals("7")){
    myTime=((myDate.getTime()/1000)-60*60*24*7)*1000;
 &n


相关文档:

动态sql语句基本语法

1 :普通SQL语句可以用Exec执行
      例:      Select * from tableName
                Exec('select * from tableName')
        & ......

linq to sql 分页 的几种方法

1.数据的分布Skip()和take()
Skip(100)代表跳过100行后.从第101行开始分页;
take(10)表示多少行分页;
例:
var result=from pdt in db.Product
                 select pdt;
this.dataview.DataSource=result.Skip(10).take(10);
......

SQL Server 语句查询手册

建表:
CREATE TABLE  [DB.dbo].tableName
(Stud_id int CONSTRAINT  constraintName1  not null primary key,
 Name nvarchar(5) not null,
 Birthday datetime,
 Gender nchar(1),
 Telcode char(12),
 Zipcode char(6) CONSTRAINT constraintName2 CHECK(zipcode like [ ......

sql事务处理


 
BEGIN TRANSACTION--开始事务
DECLARE @errorSun INT --定义错误计数器
SET @errorSun=0 --没错为0
UPDATE a SET id=232 WHERE a=1 --事务操作SQL语句
SET @errorSun=@errorSun+@@ERROR --累计是否有错
UPDATE aa SET id=2 WHERE a=1 --事务操作SQL语句
SET @errorSun=@errorSun+@@ERROR --累计是否有错
I ......

sql查找某个字符串第N次出现的位置的函数(转帖)

if exists(select 1 from sysobjects where name='char_index')
drop function char_index
create function char_index(@string varchar(8000),@char varchar(10),@index smallint)
--@string:待查找字符串,@index:查找位置
returns smallint
as
begin
  declare
  @i tinyint,--当前找到第@i个
  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号