CHECK DATE VAR in a between fields

User avatar
sal21
PlatinumLounger
Posts: 4343
Joined: 26 Apr 2010, 17:36

CHECK DATE VAR in a between fields

Post by sal21 »

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
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78394
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CHECK DATE VAR in a between fileds

Post by HansV »

Does the table FERIE contain only one record?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4343
Joined: 26 Apr 2010, 17:36

Re: CHECK DATE VAR in a between fileds

Post by sal21 »

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

User avatar
HansV
Administrator
Posts: 78394
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CHECK DATE VAR in a between fileds

Post by HansV »

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

User avatar
sal21
PlatinumLounger
Posts: 4343
Joined: 26 Apr 2010, 17:36

Re: CHECK DATE VAR in a between fileds

Post by sal21 »

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
this is for me!
Work perfect.
Tks