I have this VarData=07/01/2020.
i need to check if VarData is in a between from DAL and AL
in my case the result is true
see image.
note:
for SQL in ADo and VB 6.0 and access Database table named FERIE
CHECK DATE VAR in a between fields
-
- PlatinumLounger
- Posts: 4343
- Joined: 26 Apr 2010, 17:36
CHECK DATE VAR in a between fields
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78394
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: CHECK DATE VAR in a between fileds
Does the table FERIE contain only one record?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4343
- Joined: 26 Apr 2010, 17:36
Re: CHECK DATE VAR in a between fileds
HansV wrote:Does the table FERIE contain only one record?
Sorry, but the real table contain approx 15.xxxx records.
... and the table contain also a field MATR, is a unique Id.
In this my my ... select ... from ... where MATR='" & VarMatr & "'... ecc
-
- Administrator
- Posts: 78394
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: CHECK DATE VAR in a between fileds
Here is some code:
Code: Select all
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim sql As String
Dim bln As Boolean
Set cnn = New ADODB.Recordset
cnn.Open ConnectionString:="..."
sql = "SELECT Count(*) FROM FERIE WHERE #" & Format(VarData, "mm/yy/dddd") & _
"# BETWEEN DAL AND AL"
Set rst = New ADODB.Recordset
rst.Open Source:=sql, ActiveConnection:=cnn, Options:=adCmdText
bln = (rst(0) > 0)
rst.Close
cnn.Close
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4343
- Joined: 26 Apr 2010, 17:36
Re: CHECK DATE VAR in a between fileds
this is for me!HansV wrote:Here is some code:
Code: Select all
Dim cnn As ADODB.Connection Dim rst As ADODB.Recordset Dim sql As String Dim bln As Boolean Set cnn = New ADODB.Recordset cnn.Open ConnectionString:="..." sql = "SELECT Count(*) FROM FERIE WHERE #" & Format(VarData, "mm/yy/dddd") & _ "# BETWEEN DAL AND AL" Set rst = New ADODB.Recordset rst.Open Source:=sql, ActiveConnection:=cnn, Options:=adCmdText bln = (rst(0) > 0) rst.Close cnn.Close
Work perfect.
Tks