Skip to main content
Inspiring
January 21, 2009
Question

Get week start and end dates

  • January 21, 2009
  • 4 replies
  • 452 views
I'm currently coding a calendar where I want to diplay all event for the current week.

Can anyone tell me how to get the dates to use in the query?

Thanks
    This topic has been closed for replies.

    4 replies

    matthiscoAuthor
    Inspiring
    January 22, 2009
    Thanks Dan!

    It works great, I dunno how I go those dates in the first instance
    Inspiring
    January 21, 2009
    When I run this:
    <cfscript>
    Offset = (DayOfWeek(Now()) - 1) * -1;
    Date1 = dateadd("d", offset, now());
    Date2 = dateadd("d", 7, Date1);
    </cfscript>
    <cfdump var="#date1# and #date2#">

    I get this:
    {ts '2009-01-18 10:58:34'} and {ts '2009-01-25 10:58:34'}

    Looks like I should have only added 6 days for date2, but that's minor. How did you manage to get 2009-02-01?
    matthiscoAuthor
    Inspiring
    January 21, 2009
    Thanks for your reply.

    That gives me

    Sunday, January 18, 2009
    Sunday, February 1, 2009

    Im looking for:

    Sunday, January 18, 2009
    Sunday, January 25, 2009

    Thanks again
    Inspiring
    January 21, 2009
    For weeks starting on Sunday.

    Offset = (DayOfWeek(Now()) - 1) * -1;
    Date1 = dateadd("d", offset, now());
    Date2 = dateadd("d", 7, Date1);