Solved

Need help with query

Posted on 2014-10-02
5
166 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 35

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 35

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

773 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