sql里日期要把格式改为 月-日-年的格式 要这样写 selecct * form a where b=#" format(date,"MM-dd-yyyy") & "#" 呵呵,记得给我分呀
select * from table where Date_Field = CDate(Date_Value as string) select * from table where Date_Field > CDate(Date_Value as string) select * from table where Date_Field < CDate(Date_Value as string)
不好意思,看错了,改正:select * from table where format(Date_Field,'yyyy年m月') = '2003年6月' select * from table where format(Date_Field,'yyyy年m月') < '2004年2月' select * from table where format(Date_Field,'yyyy年m月') > '2000年2月'
我是用的accsee,还有我是菜鸟,帮我用点中文说明嘛!先谢了!
等于2003年3月,text1.text=2003-3 sql = "select * from 表 where year(日期字段) = " & Year(Text1.Text) & " and month(日期字段) = " & Month(Text1.Text) & ""大于2003年1月,text1.text=2003-1 sql = "select * from 表 where 日期字段 > #" & Text1.Text & "#"小于2003年4月,text1.text=2003-4 sql = "select * from 表 where 日期字段 < #" & Text1.Text & "#" rs.Open sql, cn
access也可以 select * from table where format(Date_Field,'yyyy年m月') < '2004年2月' 从名为table的表中查询Date_Field小于2004年2月的所有字段,其中用到了format函数VB所提供的Format函数并不像DOS的Format有相同的功能,VB的Format函数是把资料包裹成指订的样式输出。 ●用法:传回资料= Format(资料, 格式) ●简单范例。 Private Sub Command1_Click() Print Format(1234, "0#####") End Sub ●结果Prt打出:"001234" Private Sub Command1_Click() Print Format(1234, "(0#####)") End Sub ●结果Prt打出:"(001234)" Private Sub Command1_Click() Dim TlPrice As Long TlPrice = TtPrice + 430 TlPrice = TtPrice + 120 TlPrice = TtPrice + 230 Print Format(TtPrice, "总价是0#####元") End Sub ●结果Prt打出:"总价是000780元" Private Sub Command1_Click() Dim TlPrice As Long TlPrice = TtPrice + 430 TlPrice = TtPrice + 120 TlPrice = TtPrice + 230 Print Format(TtPrice, "总价是#####0000元") End Sub ●结果Prt打出:"总价是0780元" Private Sub Command1_Click() Dim MyTime As String MyTime ="12:5:6" Print Format(MyTime, "hh:mm:ss") End Sub ●结果Prt打出:"12:05:06" Private Sub Command1_Click() Dim MyTime As String MyTime ="12:5:6" Print Format(MyTime, "AMPM hh:mm:ss") End Sub ●结果Prt打出:"PM 12:05:06" Private Sub Command1_Click() Dim MyTime As String MyTime ="77/10/18" Print Format(MyTime, "倩倩的生日 yyyy/mm/dd") End Sub ●结果Prt打出:"倩倩的生日 1977/10/18" 格式说明 # 显示数字 0 在#前未满#的位数都补0、在#后未满0位数都补0 y 显示年 m 显示月或分 d 显示日 h 显示时 s 显示秒 : 时间分隔 / 日期分隔 AMPM 显示是上午或下午
要这样写
selecct * form a where b=#" format(date,"MM-dd-yyyy") & "#"
呵呵,记得给我分呀
select * from table where Date_Field > CDate(Date_Value as string)
select * from table where Date_Field < CDate(Date_Value as string)
select * from table where format(Date_Field,'yyyy年m月') < '2004年2月'
select * from table where format(Date_Field,'yyyy年m月') > '2000年2月'
sql = "select * from 表 where year(日期字段) = " & Year(Text1.Text) & " and month(日期字段) = " & Month(Text1.Text) & ""大于2003年1月,text1.text=2003-1
sql = "select * from 表 where 日期字段 > #" & Text1.Text & "#"小于2003年4月,text1.text=2003-4
sql = "select * from 表 where 日期字段 < #" & Text1.Text & "#"
rs.Open sql, cn
select * from table where format(Date_Field,'yyyy年m月') < '2004年2月'
从名为table的表中查询Date_Field小于2004年2月的所有字段,其中用到了format函数VB所提供的Format函数并不像DOS的Format有相同的功能,VB的Format函数是把资料包裹成指订的样式输出。
●用法:传回资料= Format(资料, 格式)
●简单范例。
Private Sub Command1_Click()
Print Format(1234, "0#####")
End Sub
●结果Prt打出:"001234"
Private Sub Command1_Click()
Print Format(1234, "(0#####)")
End Sub
●结果Prt打出:"(001234)"
Private Sub Command1_Click()
Dim TlPrice As Long
TlPrice = TtPrice + 430
TlPrice = TtPrice + 120
TlPrice = TtPrice + 230
Print Format(TtPrice, "总价是0#####元")
End Sub
●结果Prt打出:"总价是000780元"
Private Sub Command1_Click()
Dim TlPrice As Long
TlPrice = TtPrice + 430
TlPrice = TtPrice + 120
TlPrice = TtPrice + 230
Print Format(TtPrice, "总价是#####0000元")
End Sub
●结果Prt打出:"总价是0780元"
Private Sub Command1_Click()
Dim MyTime As String
MyTime ="12:5:6"
Print Format(MyTime, "hh:mm:ss")
End Sub
●结果Prt打出:"12:05:06"
Private Sub Command1_Click()
Dim MyTime As String
MyTime ="12:5:6"
Print Format(MyTime, "AMPM hh:mm:ss")
End Sub
●结果Prt打出:"PM 12:05:06"
Private Sub Command1_Click()
Dim MyTime As String
MyTime ="77/10/18"
Print Format(MyTime, "倩倩的生日 yyyy/mm/dd")
End Sub
●结果Prt打出:"倩倩的生日 1977/10/18"
格式说明 # 显示数字
0 在#前未满#的位数都补0、在#后未满0位数都补0
y 显示年
m 显示月或分
d 显示日
h 显示时
s 显示秒
: 时间分隔
/ 日期分隔
AMPM 显示是上午或下午