sql 語句:如何取當月的所有數據(50分)

  • 主题发起人 主题发起人 goddy
  • 开始时间 开始时间
G

goddy

Unregistered / Unconfirmed
GUEST, unregistred user!
select termdate form info where termdate like '2001-6%'
這句sql 錯誤
 
如果你的 termdate 是date型
应当写 select termdate from info where datediff(mm,getdate(),termdate)=0
 
select termdate form info where termdate between :pdate1 and :pdate2
 
看这个:
Select termdate from info
where SubString(Convert(Char,termdate,120),1,7) ='2001-06'
 
有求每月最小日、最大日的自定义函数,然后代进去:
select termdate form info where termdate >= :mindate and termdate<=:maxdate
 
select termdate form info where month(termdate)=6
 
受wind_cloudy启发
select termdate form info where year(termdate)=2001 and month(termdate)=6
 
select termdate form info where WHERE EXTRACT(MONTH FROM termdate) = 6
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
815
import
I
后退
顶部