Solved

Need help with query

Posted on 2014-10-02
5
161 Views
Last Modified: 2014-10-03
how to determine leap year in access query and add 365 days and it the year is not leap add 366
i know how to do in excel but not in access

=IF(MOD(YEAR(date),4)=0,date+365,date+366)
thank you for your help
0
Comment
Question by:rfedorov
  • 2
  • 2
5 Comments
 
LVL 34

Accepted Solution

by:
PatHartman earned 400 total points
ID: 40357944
You don't need to do that.  Use the correct function and Access will handle the problem for you.

= DateAdd("yyyy", 1, Date())

Access has a number of date functions.  I recommend getting a list and becoming familiar with what they are used for.
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 100 total points
ID: 40359274
In Access:
=IIF((YEAR(date) MOD 4)=0,date+365,date+366)
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 40359595
hnasr,
That is not the correct formula for determining leap year.  I hate to be pedantic but it was code like that which caused the Y2K "crisis".  I don't understand why you would simply not use the appropriate function.
0
 

Author Closing Comment

by:rfedorov
ID: 40359784
thanks you very much
0
 
LVL 30

Expert Comment

by:hnasr
ID: 40360257
Welcome!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now