Results 1 to 6 of 6

Thread: [RESOLVED] How do I check if a date is less then 120 days?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2008
    Posts
    79

    Resolved [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

  2. #2
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2008
    Posts
    79

    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 =)

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2008
    Posts
    79

    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() =)

  5. #5
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    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

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2008
    Posts
    79

    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
  •  



Click Here to Expand Forum to Full Width