Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Display Year between 2 dates

Display Year between 2 dates

Display Year between 2 dates


I have a table which shows a dteYear based off dteSessionDates but it's showing the wrong year, all i'm doing at the moment to get the year is:


dteYear: Format([dteSessionDates],"yyyy") 

The above isn't correct and giving off some wrong dates

03/10/2023 = 2023 (which is correct)
10/01/2023 = 2023 (which is wrong, should be 2022)

An actual year is between 1 April to 31 March of the next year.

I could put a nested If statement in the query but you're only allowed so many of them, i did see a while ago where there was a table created, with the from and to dates and the year.

DateFrom Dateto Year
01/04/2020 31/03/2021 2020
01/04/2021 31/03/2022 2021
01/04/2022 31/03/2023 2022
01/04/2023 31/03/2024 2023

You add this table to the query and do a Where statement, it must be something like

Select Year from tblDateFromTo Where dteSessions is between Datefrom and Dateto

Anyone help me out


RE: Display Year between 2 dates

You need to have a stored value of the number of months to add or subtract from the actual date to determine the calculated year. The simplest method might be to create a user defined function like:

CODE --> vba

Function GetCalcYear(datDate As Date) As Integer
    Dim intMthsAdd As Integer
    intMthsAdd = -3        'subtract 3 months from the provided date
    GetCalcYear = Year(DateAdd("m", intMthsAdd, datDate))
End Function 

Hook'D on Access
MS Access MVP 2001-2016

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close