-
VB6 - Retrieving records that is 90 days old from today's date
Hi all,
My database/table is Access 2000 and the date format in the table is "mm/dd/yyyy"
My objective is to retrieve all records that is 90 days old from today's date.
I used this code:
Code:
& "WHERE tblUnclaimed.Original_Check_Date <= #" & DateAdd("d", -90, Date) & "# " _
And my output included records from 2002 as well as 2007 which is wrong.
What is the correct code/syntax?
Thanks.
Giftx.
-
 Originally Posted by GiftX
And my output included records from 2002 as well as 2007 which is wrong.
Why is that wrong? Is not any date at all in either 2002 or 2007 greater than 90 days ago?
The answer is yes, so in fact, the output is completely correct based on what you are asking for.
Although you are getting what you are asking for, I suspect you are not getting what you want. So, perhaps you need to add an ADD clause to your query and stipulate a begin date so it does not go back into yesterday years.
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
-
Your code is fine, but you want records greater than or equal to 90 days ago:
& "WHERE tblUnclaimed.Original_Check_Date => #" & DateAdd("d", -90, Date) & "# " _
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
Dates >= a date 90 days ago gives you records that are 90 or less Days old.
Dates <= a date 90 days ago gives you records that are 90 or more Days old, no matter how much older, 1 year, 2 years, 3 years, ect.
Dates = a date 90 days ago gives you records that are exactly 90 days old.
Without knowing what he is actually trying to do, it is difficult to suggest which option. If it is not one of the three above then a date range is probably what he needs.
-
A date range is, I believe, exactly what he needs.
Something the is equal to, but not greater than, 90 days ago (which, for today, would be May 24th)
So, I'm guessing he would want greater than or equal to 5/24 and less than or equal today.
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
-
Hi Hack,
This is what I did:
Code:
Dim Todaydate As Date
Todaydate = DateAdd("d", - 90, Date)
When I ran the query, Todaydate = 5/23/2008.
Then I plugged in "Todaydate" in my sql.
Look at the hilited code within my sql. This code worked. It gave me 14 records - Records ranging from 5/29/2008 to 7/31/2008
My Sql code:
Code:
strSQL = "SELECT tblUnclaimed.PassNumber, tblUnclaimed.EmployeeName, " _
& "Original_Check_Number, Amount_of_Check, Original_Check_Date, " _
& "EmployeeInfo.Status, tblL3Desc.L3, tblL3Desc.L3_Desc " _
& "FROM (EmployeeInfo Right JOIN tblUnclaimed ON EmployeeInfo.L1 = tblUnclaimed.L1 " _
& "AND EmployeeInfo.Pass_Number = tblUnclaimed.PassNumber) LEFT JOIN tblL3Desc " _
& "ON EmployeeInfo.L1 = tblL3Desc.L1 AND EmployeeInfo.L3 = tblL3Desc.L3 " _
& "AND EmployeeInfo.L5 = tblL3Desc.L5 " _
& "WHERE tblUnclaimed.Original_Check_Date Between #" & Startdate & "# AND Now() " _
& "AND tblUnclaimed.Status = 'U' ORDER BY tblL3Desc.L3, tblUnclaimed.PassNumber;"
And that worked.
Thanks.
Giftx.
-
-
WHERE tblUnclaimed.Original_Check_Date Between #" & Startdate & "# AND Now() --- that is what did it for you, right?
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
Similar Threads
-
By mattlucas in forum VB Classic
Replies: 1
Last Post: 03-02-2005, 09:08 AM
-
By Chris in forum Database
Replies: 1
Last Post: 08-25-2002, 10:54 PM
-
Replies: 5
Last Post: 08-09-2001, 05:34 PM
-
By andy in forum Database
Replies: 1
Last Post: 02-05-2001, 01:08 PM
-
By Zane Thomas in forum .NET
Replies: 4
Last Post: 11-27-2000, 11:12 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks