Skip to main content
Participant
June 26, 2008
Answered

LTE and GTE Not Including Today

  • June 26, 2008
  • 4 replies
  • 660 views
Here's my issue. I am pulling up event records from a MySQL Database that have a range of dates during which that event will last. I want any events that have a range in which todays date falls between to be displayed, and consequently any that aren't to be disregarded. When I use cfif statements to filter the records via the LTE and GTE operators all values that fit the specifications are returned, except for any events on which today is the first date or the last date. I have attached a very simplified version of the code. Can anyone explain why this is happening?
    This topic has been closed for replies.
    Correct answer Mudbuggle
    The solution no longer eludes me.
    The cause of this issue wasn't in the code at all... It turns out the app that I had designed for inserting the start and end dates was putting bogus info into the db...
    This is what was supposed to be inserted 2008-06-26.
    Formatting isn't even needed to evaluate the dates, the code that I am currently using for the simplified version is.
    Thanks for the suggestions they helped immensly

    4 replies

    MudbuggleAuthorCorrect answer
    Participant
    June 27, 2008
    The solution no longer eludes me.
    The cause of this issue wasn't in the code at all... It turns out the app that I had designed for inserting the start and end dates was putting bogus info into the db...
    This is what was supposed to be inserted 2008-06-26.
    Formatting isn't even needed to evaluate the dates, the code that I am currently using for the simplified version is.
    Thanks for the suggestions they helped immensly
    Inspiring
    June 30, 2008
    > I want any events that have a range in which todays date falls between to be displayed,
    > and consequently any that aren't to be disregarded

    Then it would probably be more efficient to filter the query on start/end date. So the query contains only the events you need to display. There is no reason to retrieve extra records that will never be used.

    MudbuggleAuthor
    Participant
    June 26, 2008
    They are formaed in the db, however the options are limited to Date and DateTime. I have tried setting the date format in the db to DateTime (yyyy-mm-dd hh:mm:ss) with all of the dates set to midnight, and date (yyyy-mm-dd). I removed the <cfset ...DateFormat()...> and used the #now()# in place of #DATE#... didn't make any difference. I also attempted using the following.
    <cfif DateCompare(#DATE#, #StartDate#, "d") GTE 0>
    <cfif DateCompare(#DATE#, #EndDate#, "d") LTE 0>
    I have swapped the #DATE# with the #now()# function still no change in result.I decided to try the following, which didn't work either.

    Known Participant
    June 26, 2008
    Try removing the <cfset ...dateFormat ..>

    Also how are the dates stored in the db - are they stored formated? do they have time elements or are they all set to midnight?

    Michael