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

Get week start and end dates

Explorer ,
Jan 21, 2009 Jan 21, 2009
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
421
Translate
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 ,
Jan 21, 2009 Jan 21, 2009
For weeks starting on Sunday.

Offset = (DayOfWeek(Now()) - 1) * -1;
Date1 = dateadd("d", offset, now());
Date2 = dateadd("d", 7, Date1);
Translate
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
Explorer ,
Jan 21, 2009 Jan 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
Translate
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 ,
Jan 21, 2009 Jan 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?
Translate
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
Explorer ,
Jan 22, 2009 Jan 22, 2009
LATEST
Thanks Dan!

It works great, I dunno how I go those dates in the first instance
Translate
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