Access: Select * From YourTable Where DateField Between #2004-10-11# And #2004-12-12#SQLServer: Select * From YourTable Where DateField Between '2004-10-11' And '2004-12-12'
用Between And 就可以了, 记得在ACCESS要用##括住日期 在SQL SERVER 中用‘’括住日期
'vb、SQLServer的写法:Option Explicit Public mConnString As StringPrivate Sub Command1_Click() Dim mRst As New ADODB.Recordset mRst.CursorLocation = adUseClient mRst.Open "Select * From 表111 Where 收费日期 Between '" & DTPicker1.Value & "' And '" & DTPicker2.Value & "'", mConnString, adOpenStatic, adLockOptimistic, adCmdText MsgBox mRst.Fields(0) End SubPrivate Sub Form_Load() mConnString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=test;Data Source=server" End Sub
Select * From YourTable Where DateField Between #2004-10-11# And #2004-12-12#SQLServer:
Select * From YourTable Where DateField Between '2004-10-11' And '2004-12-12'
记得在ACCESS要用##括住日期
在SQL SERVER 中用‘’括住日期
Public mConnString As StringPrivate Sub Command1_Click()
Dim mRst As New ADODB.Recordset
mRst.CursorLocation = adUseClient
mRst.Open "Select * From 表111 Where 收费日期 Between '" & DTPicker1.Value & "' And '" & DTPicker2.Value & "'", mConnString, adOpenStatic, adLockOptimistic, adCmdText
MsgBox mRst.Fields(0)
End SubPrivate Sub Form_Load()
mConnString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=test;Data Source=server"
End Sub