General Date Data - DCOUNT based on User Defined Short Date

surfdude300zx

New member
Local time
Yesterday, 18:15
Joined
Sep 19, 2012
Messages
2
Hi there!! My first post!!

Based on a short date given by the user -UserGivenDate 9/18/2012 -inputed in a text box I want the dcount function to go through a data field (DateGeneral) and count how many times that date occurs. Now, the data is formated as a general date so it looks like this 9/18/2012 8:23:00 PM. This is the code I have been useing.

DateGeneralCount = DCount("DateGeneral", "DCount", "DateGeneral = UserGivenDate")
Text6.Value = DateGeneralCount

This runs and returns the value 0 to Text6

If you type in 9/18/2012 8:23:00 PM the exact date and time of a data point it will come up with count 1. But if you type 9/18/2012 it will come up with count 0 even though there is an instance where this date occurs.


Any help would be Great Thanks!!!
 
Can you not change the first data type to be datetime General Date?
 
Welcome to the forum.

You may get some inspiration from the discussion here, which concerns the compassion of dates using the DLookup() function.
 
First create a query to get the date only using DateValue:

MyNewName:DateValue([DateGeneral])


And save it. Then you can get the counts (I assume that UserGivenDate is a control on the form):

DCount("*", "QueryNameHere", "[DateGeneral]=#" & Me.UserGivenDate & "#")
 
... if you don't need the time portion of the date in your stored value use the Date() function in preference to the Now() function.
 

Users who are viewing this thread

Back
Top Bottom