Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 778959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:51:03+00:00 2026-05-14T19:51:03+00:00

I have 3 fields in my table: start, end (dates) and length (number, might

  • 0

I have 3 fields in my table: start, end (dates) and length (number, might be blank).
My Aim is to calculate an end date using start and length where end doesn’t exist…

I have:

SELECT Switch((g.length<>0) And IsDate(g.end),DateAdd("m",g.length,g.start)) AS field FROM table g

If there is no start, end or length, Access displays blank – this is fine.
If there is no end, but start and length are ok, the calculated date is shown – again fine.
BUT
If there is no end, or length, but a start exists, access displays #Error

I don’t understand why, and can’t fix it, please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T19:51:04+00:00Added an answer on May 14, 2026 at 7:51 pm

    If there is no end, but start and length are ok, the calculated date is shown

    Are you certain about that point? When I try your query with values for start and length, but no value for end, I get a Null for “field”.

    Also, you’re calling the DateAdd function when this condition is True:

    g.length<>0) And IsDate(g.end)
    

    In order for that condition to be True, g.end would have to already contain a valid date … but I thought you didn’t want to perform the calculation when you already have a value for g.end. I’m confused.

    Let’s try a different approach. If this query returns what you want, good. If not help us understand why it is incorrect.

    SELECT
        d.start,
        d.end,
        d.length,
        IIf(IsDate(d.end), d.end,
        IIf(Nz(d.length)>0, DateAdd("m", d.length, d.start), Null)) AS field
    FROM table AS d;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql table with fields for a start and end date/time. How
I have a (MySQL) table with two date/time fields: start and end (each of
I have a table with three date fields, a start date, mid-term date, and
I have a table in mysql that holds a start and end date field.
I have 2 tables: matches TABLE FIELDS: record, date, competition outrights TABLE FIELDS: record,
We have a from date and To date in Table fields. We are getting
I have a deals table, with a field start date in the controller i
I have a table with two fields, date_start & date_end, both are date fields.
i have payment table fields update reason and amount & total field are change
i have some fields in my database table,and a field with phone name ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.