?
Solved

If-then-else statement for dates

Posted on 2014-02-19
4
Medium Priority
?
276 Views
Last Modified: 2014-02-19
Not sure how to write vb If statement with dates such as:

 If txtCalDate is > 30 days  Then etc..



Thanks
0
Comment
Question by:zkoda
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39871664
can you explain in plain english this line

 If txtCalDate is > 30 days


what is in "txtCalDate" ?
0
 

Author Comment

by:zkoda
ID: 39871680
Sorry - txtCalDate is the name of a field in a form.  If the date value is greater than 30 days then I'll take it from there.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 39871698
<If the date value is greater than 30 days > you need two dates to do a comparison?

assuming the second date is todays date


if datediff("d",Date(),me.txtCalDate) > 30 then



end if

or

if datediff("d",me.txtCalDate,Date()) > 30 then



end if
0
 

Author Closing Comment

by:zkoda
ID: 39871709
Just what I needed - Thanks
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question