473,386 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Access/Query - IIF Statement + Current Date To Calculate New Date

Hello All,

I'm trying to generate a query using an IIF statement where I need to calculate a new date based the current date.

Basic premis: If DateA is >= to current date, I want to use DateA+30, otherwise use DateB+30

Program: Microsoft Access 97

Here's my iif statement:

IIf([Table]![DateA]>=Today(),([Table]![DateA]+30),([Table]![DateB]+30))

I keep getting an error:
Compile Error in query expression; I don't believe I have a syntax error. Anyone have any suggestions or ideas on how to approach this for a resolution?

Any help would be appreciated!

Thanks!
BenAd
Jul 24 '12 #1
1 3602
Seth Schrock
2,965 Expert 2GB
SQL uses a period between the table name and the field name, so you should have something like
Expand|Select|Wrap|Line Numbers
  1. Table.DateA
I don't believe that Today() is a command that SQL recognizes. Instead, use the Date() function

Also, I don't believe that you will get the proper results from DateA+30. You would probably need to use the DateAdd function. Here is a website that can give you detailed instructions for how this function works: MS Access: DateAdd Function

Overall, this is what I would use:
Expand|Select|Wrap|Line Numbers
  1. SELECT IIF(DateA>=Date()
  2. , DateAdd("d",30,DateA)
  3. , DateAdd("d",30,DateB)) AS AddedDate
  4. FROM Table
Jul 24 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: George Stout | last post by:
First off I do not know alot about writing queries to an Access Database from an ASP page. This is why I need help. I have an Events database for 6 colleges in our metro area. On the homepage I...
2
by: Douglas | last post by:
Can somone help me contruct a simple query Basically I want my query to extract records where the MOT_Due_Date is between the 1st Day of the current month and the date 6 weeks from the 1st day...
1
by: Brian Jorgenson | last post by:
I am looking for a formula to put in my query to pull data based on the last 3 months. It starts with the current day and will go back 3 months. Here is my wrkflow language for example: ...
8
by: s_wadhwa | last post by:
SELECT DISTINCTROW "01C" AS dummy, Buildings.BuildingNumber, UCASE(Buildings.BuildingName) AS BuildingName, Buildings.MasterPlanCode, Buildings.UniformBuildingCode,...
3
by: Idlemind23 | last post by:
Ahoy! I'm hoping for some help on what (I believe) should be a simple task. I have a form with a button. I would like that button to have a caption with a date. That date should be pulled out...
1
by: LSGKelly | last post by:
Hi all...I need to convert an EOMONTH statement into an Access Query. The current formula looks like this: =EOMONTH(B16,(-1)) B16 now = ProposedEffDate Is there a function in Access that...
1
by: aneinander | last post by:
I'm beginner and getting following error message, please help. The table contains transaction date, account number, branch, etc. And need to show previous transaction date or next transaction date...
8
by: trixxnixon | last post by:
i want to use the date from a date field that also has the time stamp and calculate it within an access query. WHERE Day(DateSerial(<d>, <m>, <y>))=<d> would it be possible to only include the...
0
by: uno7031 | last post by:
Help Please!!! Adding 5 Days to another Date in an access query Good Morning, Help please…. I am new to access and trying to write a query that will add 5 days between a RecDate and a...
3
by: zandiT | last post by:
Hello I have an access report and im using a query to filter the report using Date parameters eg Start Date-12 May 2009 and End Date-30 September 2009. the query works perfectly. My problem is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.