• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Overlapping dates

New Here ,
May 21, 2007 May 21, 2007

Copy link to clipboard

Copied

Hi, trying to work out how to check wether Form.startDate and Form.endDate fall in between other start or end dates in the database... currently using

SELECT cmsPollsID
FROM cmsPolls
WHERE '#Trim(FORM.eventStartDate)#' BETWEEN cmsPolls.liveStartDate and cmsPolls.liveEndDate
AND '#Trim(FORM.eventEndDate)#' BETWEEN cmsPolls.liveStartDate and cmsPolls.liveEndDate

works when the start date is between dates but not the end date.

Thanks
TOPICS
Advanced techniques

Views

390

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 21, 2007 May 21, 2007

Copy link to clipboard

Copied

First, if you are using the trim function, you may be storing your dates as char instead of date datatype. Bad idea

Next, what are some of the values where you don't think it's working?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 21, 2007 May 21, 2007

Copy link to clipboard

Copied

I agree about the dates. Storing date values as strings is bad news.

If you want to check whether either the start or end date fall between another range, use OR instead of AND. You may also want to check whether they span another range.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 21, 2007 May 21, 2007

Copy link to clipboard

Copied

LATEST
Thanks heaps for that
that worked heaps better !

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation