|
-
Mar 9th, 2008, 12:27 PM
#1
Thread Starter
Lively Member
[RESOLVED] How do I check if a date is less then 120 days?
Ok, this one is beyond me. None the less, I need some guru help to accomplish this. This is where your expertise comes in...
I have SQL statement retrieve a Date from a field in an Access database to be displayed in a textbox txt(2).Text. This particular date is an expireration date. I need to check to make sure that this date is not less than 120 days. If it is I will have my code mark it as RED to the user.
I already have my SQL statement working fine for retrieving the specific date and displaying it in txt(2).Text. My issue is that I do not know the proper coding to check if the specific date is < 120 days.
I am using VB6 for all my coding needs.
Thank you all for your time and efforts,
Azeccia
-
Mar 9th, 2008, 12:35 PM
#2
Re: How do I check if a date is less then 120 days?
Use DateDiff() funcion.
Code:
If DateDiff("d", Date, ExpirationDate) < 120 Then
...
End If
-
Mar 9th, 2008, 12:44 PM
#3
Thread Starter
Lively Member
Re: How do I check if a date is less then 120 days?
Ok thank Logophobic
I am not as familar with the, "ins-and-outs" of the DateDiff() so I will start reading up on it. So I can use the syntax correctly. But you certainly pointed me in the right direction now =)
-
Mar 9th, 2008, 12:53 PM
#4
Thread Starter
Lively Member
Re: How do I check if a date is less then 120 days?
After a quick search on the DateDiff() and re-reading your post Logophobic,
Based from your example:
If DateDiff("d", Date, ExpirationDate) < 120 then
Does the "d" = days?
Date = The Date Format?
ExpirationDate = The actual date from the Access date field?
If I am correct then I think I am starting to figure out how to properly use the DateDiff() =)
-
Mar 9th, 2008, 12:57 PM
#5
Re: How do I check if a date is less then 120 days?
try this
Code:
Dim days As Integer
days = DateDiff("d", "02-26-08", Now)
If days < 120 Then
MsgBox "i'm less than 120 days"
End If
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Mar 9th, 2008, 01:07 PM
#6
Thread Starter
Lively Member
Re: How do I check if a date is less then 120 days?
Sweet!
You guys are good. Thank you both for your great feedbacks.
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
|
Click Here to Expand Forum to Full Width
|