Date Between recordset

Results 1 to 2 of 2

Thread: Date Between recordset

  1. #1
    Scott Wilson Guest

    Default Date Between recordset

    &nbsp;<BR>Can somone help us with the following please.<BR><BR>We have records (in DateRecords) that contain two dates &#039DateStart&#039 and &#039DateEnd&#039<BR>DateStart represents the beginning of the month (12/01/00) and DateEnd represents the end of the month (12/31/00).<BR><BR>ThisDate is today&#039s date. I just want to find records that contain the DateStart and DateEnd of the same month of today&#039s date. <BR><BR>For instance since today is 12/2/00 I want to find records that fall in between 12/1/00 and 12/31/00. If today was 1/2/01 then it would then search for records that fall in between 1/1/01 and 1/31/01.<BR><BR><BR>Seems like it shouldn&#039t be that hard but I&#039m getting NULL errors and I have plenty of records that contain Dec. records. ( ie. DateStart = 12/1/00, DateEnd = 12/31/00).<BR><BR>I&#039m using MS Access 2000<BR><BR>&#060;%<BR> dim thisdate<BR> dim finddate<BR> thisdate = Date<BR> Set finddate =Server.CreateObject("ADODB.recordset")<BR>sql="SE LECT * FROM DateRecords where DateStart &#062;= #"&thisdate&"# AND DateEnd &#060;= #"&thisdate&"# " <BR> Set finddate.ActiveConnection = objConn<BR> <BR>%&#062;<BR>

  2. #2
    Richard A. Lowe Guest

    Default RE: Date Between recordset

    Rather than try to get the range of dates, you can just search where the month = 12. Look at the datepart function in Access. Returning the month value is something like:<BR><BR>SELECT * FROM <BR>DateRecords <BR>WHERE DatePart(&#039m&#039, DateStart) = 12<BR>AND DatePart(&#039m&#039, DateEnd) = 12<BR><BR><BR>That would return all rcords where the start and end date were in December (check the sytnax tho... it&#039s been 6 months at least since I&#039ve used it).<BR><BR>Richard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts