易截截图软件、单文件、免安装、纯绿色、仅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 语句

select * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','1984-04-18',null);
UPDATE pet set birth='1989-08-31' WHERE name='Slim';
select * from pet WHERE birth>'1998-1-1';
SELECT * from pet WHEREselect * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','198 ......

SQL查询时间返回格式

Select CONVERT(varchar(100), GETDATE(), 23);
返回形式:2008-11-29
Select CONVERT(varchar(100), GETDATE(), 102)  
返回形式:2008.11.29
Select CONVERT(varchar(100), GETDATE(), 101)
返回形式:11/29/2008
更多详情请参见如下列表:
Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 ......

NHibernate执行原始SQL代码的方法小结

在使用NHibernate过程中经常会使用到复杂的sql查询,但是使用hql又比较麻烦的情况下,我们往往都会想到采用原始的sql来执行。但是如何利用NHibernate来执行sql呢?问题来了,在NHibernate中也有AdoTemplate的方法可以执行sql的,但是这里要介绍的是另外一种方法:CreateSQLQuery。以下部分例子源自于网络。
实例一(源自于 ......

sql 去空格与连接特殊字符

在分组排序过程中需要新建排序列,按条件:(物料分类+客户名称) 进行分组汇总 然后就根据该条件进行排序
1.需要拼凑两列 作为排序列,如需加入特殊字符.就会报错.
   因为本身改字段就是varchar类型 需要将char类型'_' 转换成varchar
2.拼凑过程中有空格需要去空格
 e.g:select (trim(物料分类)+to_char( ......

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号