Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

Date filter

Experts, how would I modify the below so instead of entering the number of days, I can enter a date such as 3/31/15

thank you
Between Date() And Date()+Nz([Enter Number of Days in Future],100000) Or Is Null
0
pdvsa
Asked:
pdvsa
  • 6
  • 6
  • 4
  • +1
3 Solutions
 
Mike EghtebasDatabase and Application DeveloperCommented:
Between Date() And DateAdd("d",Nz([Enter Number of Days in Future],0), Date())
0
 
pdvsaProject financeAuthor Commented:
Is that using either days or a date?
0
 
pdvsaProject financeAuthor Commented:
seems like entereing a date as 3/31/2015 gives me a message of "too complicated to evaluated."

any other idea?
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
Jeffrey CoachmanMIS LiasonCommented:
Not exactly sure what you are after, ...but try this works as a *simple* test
   
    Between Date() And [EnterDate]
0
 
pdvsaProject financeAuthor Commented:
yes that works.,  wouldnt I need a null handler too?
0
 
pdvsaProject financeAuthor Commented:
Between Date() And [EnterDate] Or Is Null

correct?
0
 
Rey Obrero (Capricorn1)Commented:
Between Date() And Nz([Enter Date], Date())
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
pdvsa,

No, null is already taken care of with NZ.

Mike
0
 
Rey Obrero (Capricorn1)Commented:
if your date field does not contain the time values

Between Date() And Nz([Enter Date], Date())  ' if you do not enter a value, will use the same Date as the value


if your date field contains time

Between Date() And Nz([Enter Date], Date() + 1)
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
pdvsa,

It will be helpful to address experts so we will know whom you are responding to. Did you try:

Between Date() And DateAdd("d",Nz([Enter Number of Days in Future],0), Date())

You will be prompted "Enter Number of Days in Future" here you will enter 1000 for example to see the result after a click on OK.
0
 
pdvsaProject financeAuthor Commented:
Jeff:  your formula works if I add "Or Is Null"
Between Date() And [EnterDate] Or Is Null
I have 78 records.

Rey:  
It seems that both formulas do not pick up Nulls.

Between Date() And Nz([Enter Date], Date() + 1)
Between Date() And Nz([Enter Date], Date())

I have 48 records on both of the formulas.  I tested both more than once.
the field is formatted as date in the table.  Some are null.  Its an import from excel.  Maybe there is something odd with the data in the column but it looks like the only data in the column is either a date or null.


eghtebas:  I was looking to move away from entering the number of days.  It looks as though your formula doesnt take this into account.
0
 
Rey Obrero (Capricorn1)Commented:
Rey:  
It seems that both formulas do not pick up Nulls.

Between Date() And Nz([Enter Date], Date() + 1)
Between Date() And Nz([Enter Date], Date())

it will Not.. it is suppose to filter only date values..
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
Between Date() And (Nz([Enter Date], Date()) + 1)

Null being, user enters blank.

Do you want when user enters nothing, to show all?
0
 
Jeffrey CoachmanMIS LiasonCommented:
FWIW, ...
If this was my project...
I would create a form to enter this "date"
Then use this date to filter the form.

I would "Validate" for nulls and filter the form like this:

Private Sub Command13_Click()
If Me.txtYourDate = "" Or IsNull(Me.txtYourDate) Then
   MsgBox "You must enter a date."
   Me.txtYourDate.SetFocus
   Exit Sub
End If
    Me.Filter = "[Orderdate] Between " & "#" & Date & "#" & " And " & "#" & Me.txtYourDate & "#"
    'MsgBox Me.Filter
    Me.FilterOn = True
End Sub


This way I would have more control over the output, ...I could also remove the filter easily.

I hate just using a parameter prompt because a user could enter anything they wanted: 8/2014, ...December 14, ...6/T/14 (all invalid dates)

simple sample db attached.

JeffCoachman
Database45.mdb
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
How about:

nz([MyDateField],Date()) Between Date() And (Nz([Enter Date], Date()) + 1)
0
 
pdvsaProject financeAuthor Commented:
I will award points to Jeff.  Let me know if any objections.
0
 
Jeffrey CoachmanMIS LiasonCommented:
I would prefer if you split the points between all three of us...


Jeff
0
 
Jeffrey CoachmanMIS LiasonCommented:
My post was just a suggestion of an alternative approach.
capricorn1 and eghtebas had solutions to your question as you posted it.

So a split seems like the right thing to do here...
;-)

Enjoy your weekend
0
 
Mike EghtebasDatabase and Application DeveloperCommented:
pdvsa, It is ok with me.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 6
  • 6
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now