473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Do you know why when using Between and... dates from the 1st to the 9th do not show

When using the WHERECondition "Between And".
The dates range from the 1st to 9th do not filter in to the report but if I set the date from the 31st to 10th then they do.
Do you know why this happens?
If I hard code the query or use a parameter it filters fine.

I have tried changing the variables to strings, CDATE, DATEVALUE, format etc. am i missing something out ?
They all do the same

This is the code that runs
Expand|Select|Wrap|Line Numbers
  1. Sub TxtFinishDate_Exit()
  2.  
  3.   TxtDateStart = [Form_Frm Choose What To Print].TxtStartDate.Value
  4.   TxtDateEnd = [Form_Frm Choose What To Print].TxtFinishDate.Value
  5.  
  6.   MYWhereCondition = "[Delivery_Date] Between #" & TxtDateStart & "# And #" & TxtDateEnd & "#"
  7.  
  8. 'this is an alternate line of code
  9. 'MYWhereCondition = "[Delivery_Date] Between " & Format(TxtDateStart, "\#dd/m/yyyy hh:mm\#") & " And " & Format(TxtDateEnd, "\#dd/m/yyyy hh:mm#")
  10.  
  11.   ' this code is for checking string oputputs in the imediate window
  12.   Debug.Print "From Sub TxtFinishDate_Exit :" & "[Delivery_Date] Between " & Format(TxtDateStart, "\#dd/m/yyyy hh:mm\#") & " And " & Format(TxtDateEnd, "\#dd/m/yyyy hh:mm\#")
  13.   Debug.Print "From Sub TxtFinishDate_Exit :" & MYWhereCondition
  14.  
  15.   If Not (IsNull(TxtDateStart) Or IsNull(TxtDateEnd)) Then
  16.  
  17.     DoCmd.OpenReport "Rpt Access Export Without Matching Definitions by date range1", acViewPreview, WhereCondition:=MYWhereCondition
  18.  
  19.   Else
  20.     MsgBox "You must specify both dates before opening the report"
  21.   End If
  22. End Sub
Oct 6 '10 #1
3 1433
dsatino
393 256MB
The date field you're querying is probably not formatted as you believe.

For instance, it may also be time stamped so your end date of 9/9/2010 is actually 9/9/2010 00:00:00 which means that anything after the 0th millisecond of the ninth won't be picked up. This doesn't explain why the first of the month is excluded though so this probably isn't the format, but you get the idea: check the original format of the field.
Oct 6 '10 #2
MMcCarthy
14,534 Expert Mod 8TB
Change this ...
Expand|Select|Wrap|Line Numbers
  1. Between " & Format(TxtDateStart, "\#dd/m/yyyy hh:mm\#") & " And
to ...
Expand|Select|Wrap|Line Numbers
  1. Between #" & Format(TxtDateStart, "dd/mm/yyyy hh:mm") & "# And
Fistly the correct month format is mm not m.
Secondly by putting the # indicators in the format it may be seeing it as a string instead of a date. Not sure though why it would only be doing it for the 1-9 dates.

Try these changes and see if it makes a difference.
Oct 6 '10 #3
NeoPa
32,556 Expert Mod 16PB
Your date format is local and not SQL. SQL has it's own format for dates, which happens to match the local version for USA (See Literal DateTimes and Their Delimiters (#) for a full explanation).
Oct 6 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
7
by: Egor Shipovalov | last post by:
I'm implementing paging through search results using cursors. Is there a better way to know total number of rows under a cursor than running a separate COUNT(*) query? I think PostgreSQL is bound...
0
by: Luis E Valencia | last post by:
Dim backUpDB2 As SqlClient.SqlCommand backUpDB2 = New SqlClient.SqlCommand backUpDB2.CommandType = CommandType.StoredProcedure backUpDB2.CommandText = "msdb.dbo.SP_RESUMENFAC" ...
4
by: Nuno Magalhaes | last post by:
I'm doing a "low level" server with sockets and trying to read the HTTP data from server. socket.Available at the beginning is 0 and I don't know when an HTTP page is completly read since...
11
by: Lauren Quantrell | last post by:
I already figured out (the hard way) I need to convert all my date parameters into USA format before executing my stored procedures where dates are used as parameters. (Format(StartDate, "m/d/yyyy...
1
by: jacksonec | last post by:
I am trying to use date fields in calculations so I know when a date is within 3 months of an expirationDate.
2
by: bienwell | last post by:
Hi all, I still have a problem when using Confirmation box in ASP.NET program. I need to get the value return of YES or NO from confirmation box in Sub function of VB program to do some tasks....
10
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005 and .net 2.0. I started 2 threadpool threads. How do I know when they're done with their tasks? Thanks. ThreadPool.QueueUserWorkItem(new...
3
manoj9849967222
by: manoj9849967222 | last post by:
Hi All I have a great problem. Is there a way to filter records using dates. I have a table called sales. now i want to filter record say from 1/1/2006 to 1/1/2007. which would show me the sales...
11
by: rb0135 | last post by:
Hi all (and Mark). As I have posted a few times the last few weeks about my GPS application, I have got to the point of adding the GPS stuff in. I am using the Windows Mobile 6 SDk and used the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.