pulling information between 2 dates

  • Thread starter ryan.fitzpatrick3
  • Start date
R

ryan.fitzpatrick3

I have to textboxes one with start date and one with end date, I put
dates in there and I'd like it for when I hit a runquery button it'll
pull all dates between those respective dates. here's the code I have
so far

If Not IsNull(Me.tboxStartDate) Then
strWhere = strWhere & "([MonDayYear] >= " & Format
(Me.tboxStartDate, conJetDate) & ") AND "
End If

If Not IsNull(Me.tboxEndDate) Then
strWhere = strWhere & "([MonDayYear] < " & Format
(Me.tboxEndDate, conJetDate) & ") AND "
End If


When I run this query, with the date range 1-1-2009 and 2-1-2009 it
will pull all the information where the dates fall in january but the
years will be every year. So the all the dates in january works but
not the year part.

for example i'll get

1/3/2007
1/20/1997
1/1/2008
1/30/2009

etc,

How do I get the years to program correctly?

Ryan
 
J

John W. Vinson

I have to textboxes one with start date and one with end date, I put
dates in there and I'd like it for when I hit a runquery button it'll
pull all dates between those respective dates. here's the code I have
so far

If Not IsNull(Me.tboxStartDate) Then
strWhere = strWhere & "([MonDayYear] >= " & Format
(Me.tboxStartDate, conJetDate) & ") AND "
End If

If Not IsNull(Me.tboxEndDate) Then
strWhere = strWhere & "([MonDayYear] < " & Format
(Me.tboxEndDate, conJetDate) & ") AND "
End If


When I run this query, with the date range 1-1-2009 and 2-1-2009 it
will pull all the information where the dates fall in january but the
years will be every year. So the all the dates in january works but
not the year part.

for example i'll get

1/3/2007
1/20/1997
1/1/2008
1/30/2009

etc,

How do I get the years to program correctly?

Ryan

What's conJetDate? What does strWHERE evaluate to in this process? It sounds
like your Format() is explicitly stripping off the year information.

Also, what's the datatype of MonDayYear? Text (bad) or DateTime (much easier)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top