Insert System Date into query automatically
I have an access query that I want to automatically insert the system date into for Start Date and End Date so it will query automatically query only for records that were entered today.
I am currently prompting the user to enter the date manually e.g. Enter Start Date and Enter End Date with the following criteria;
Between [Enter Start Date] And [Enter End Date]
Can this be done?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
Now() includes date and time, so Format(Now, "mm/dd/yyyy") strips off the time part; but you could just use Date() which only returns the date, no time part.
In your query, you are using Between, but if you are only looking for one day then you don't need Between which requires both a start and end value. Just change the criteria to Date()
Dateadd might be what you are looking for
To be short, I just thought:
where date_field_in_table between date() and dateadd("d", 1, date())
just maybe, it could be:
where date_column_in_table between Format(Now, "mm/dd/yyyy") and dateadd("d", 1, Format(Now, "mm/dd/yyyy"))
one of this two might work.
if you want between right now and the next 24 hours
where date_column_in_table between now and dateadd("h", 24, now)
this last one should be a pretty good approximation.
By matrik02 in forum VB Classic
Last Post: 05-11-2007, 01:33 AM
By sandhya.o.k in forum .NET
Last Post: 01-06-2007, 12:50 AM
By Urbaud in forum VB Classic
Last Post: 07-30-2006, 11:50 PM
By HEADACHE in forum Database
Last Post: 10-25-2001, 04:46 AM
By Bob Hines in forum Database
Last Post: 04-27-2000, 12:14 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL