Skip to main content
Inspiring
May 17, 2006
Question

Week/Date Question

  • May 17, 2006
  • 4 replies
  • 457 views
I am trying to write a script to determine how many orders came in this week. I am not sure how to accomplish this? Can anyone help shed some light on this?

Thanks,
Chris
    This topic has been closed for replies.

    4 replies

    EnergyFedAuthor
    Inspiring
    May 17, 2006
    Dan should I use that in a cfset statement or is that used in the sql?

    Sorry to sound like such a noob, but I always have problems when it comes to dates. My database (MySql) is picky and I didn't set it up so I can't change it.
    Inspiring
    May 17, 2006
    quote:

    Originally posted by: EnergyFed
    Dan should I use that in a cfset statement or is that used in the sql?

    Sorry to sound like such a noob, but I always have problems when it comes to dates. My database (MySql) is picky and I didn't set it up so I can't change it.

    It's the syntax one uses inside a cfscript tag, my preferred way of coding.
    EnergyFedAuthor
    Inspiring
    May 17, 2006
    Charles, normally I would do something like that. However I am going to be using it as an included stat that I want to automatically update and give the recordcount.
    Participant
    May 17, 2006
    There is a few different things you can do depending what you want to achieve.

    If you want the orders from the last week run a query like this:

    .....where order_date > #dateadd("ww", -1, now())#

    A more powerful way would be to offer the user to select the start and end date for the query, then run something like:

    ...where order_date between #form.start_date# and #form.end_date#

    Inspiring
    May 17, 2006
    Assuming your week starts on Sunday.

    StartDate = createdate(year(now()), month(now()), day(now());
    while (DayofWeekAsString(StartDate) is not "Sunday") {
    StartDate = dateadd("d" -1, StartDate);
    }

    That should get you started.