ACCESS的话
select * from table where date1<#2008-1-20# and date2>#2007-8-30#
MYSQL的话
select * from table where date1<'2008-1-20' and date2>'2007-3-30'
也可以
select * from table where date1 between '2008-1-20' and '2007-3-30'
其中date1,date2都是日期类型的字段
select * from jy_jjgl a ,jy_jygl b where convert(varchar(10),a.shtime,120)='2007-11-27' 1.显示本月第一天 SELECT DATEADD(mm,DATEDIFF(mm,0,getdate()),0) 2.显示本月最后一天 select dateadd(day,-1,convert(datetime,convert SELECT dateadd(ms,-3,DATEADD(mm,DATEDIFF(mm,0,getdate()),0)) 4.本月的第一个星期一i select DATEADD(wk,DATEDIFF(wk,0, dateadd(dd,6-datepart( SELECT DATEADD(yy,DATEDIFF(yy,0,getdate()),0) 6.本年的最后一天 SELECT dateadd(ms,-3,DATEADD(yy,DATEDIFF(yy,0,getdate())+1,0)) 7.去年的最后一天 SELECT dateadd(ms,-3,DATEADD(yy,DATEDIFF(yy,0,getdate()),0)) SELECT DATEADD(qq,DATEDIFF(qq,0,getdate()),0) SELECT DATEADD(wk,DATEDIFF(wk,0,getdate()),0) select * from tableName where DATEPART(mm, theDate) 11.查询本周的记录 select * from tableName where DATEPART(wk, theDate) = DATEPART 12查询本季的记录 注:其中:GETDATE()是获得系统时间的函数。 select * from tableName where DATEPART(qq, theDate) = DATEPART 13.获取当月总天数: select DATEDIFF(dd,getdate(),DATEADD select datediff(day, 14.获取当前为星期几 DATENAME(weekday, getdate()) |
文章评论(0条评论)
登录后参与讨论