Calendar

Jason Ortman asked on May 17, 2017 16:20

Is there a way to only display current month dates? My calendar stats with April 30 and also has June 1 - 10 and I want to remove these from showing up from month to month.

Recent Answers


Brenden Kehren answered on May 17, 2017 16:50

In your where statement for your webpart put this SQL statement (may need to update EventTime to your field name):

EventTime BETWEEN DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)
     AND DATEADD(DAY, -1, DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) + 1, 0))
0 votesVote for this answer Mark as a Correct answer

Jason Ortman answered on May 18, 2017 18:28

Do I need to add EventTime to my Calendar web part or event page type?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 18, 2017 18:41

What ever the date field is named on your page type is what you enter in the where clause. I'm assuming there is already one there for a start date, so enter that one.

0 votesVote for this answer Mark as a Correct answer

Jason Ortman answered on May 18, 2017 19:33

I was able to get this working but this is not what I am trying to do. What I am trying to do is only display the current month dates and not the previous month's and next month dates. I want all the events that I have created to still show up when you go to the next month.

So...May will only show May 1 - May 31 and not April 30 and not June 1 - June 10. June will only show June 1 - June 30.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 18, 2017 19:53

This will get what you're looking for. Your question was in regards to getting events for the current month.
Now need to implement some selector for going month to month and update your where statement based on that. Your selector could be something as simple as a link that has a query string appended to it with the month number in it.

0 votesVote for this answer Mark as a Correct answer

Mike Bilz answered on May 18, 2017 20:08

Hi Jason,

It sounds like you just want to change what is displayed on the calendar, correct?

You can handle this through CSS styling after you make some changes to the back end code by adding a skin to your calendar. (Brenden's answer to my question here will give you a good run down on the process: https://devnet.kentico.com/questions/styling-the-cms-calendar-web-part )

Once you have your skin started you can add the line <OtherMonthDayStyle CssClass="CalendarOtherMonth" />

This will let you style the days of other months to look however you would like, and to hide the events that occur in those months.

-mike

0 votesVote for this answer Mark as a Correct answer

Jason Ortman answered on May 18, 2017 20:29

I just want to only display the days of the current month and not have the months overlap. Don't think I am asking correctly.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 18, 2017 20:33

Jason, the query I provided will give the current month data. What you want on top of it though is to be more dynamic and automatically change based on a month selected VS. just a current month. So like I mentioned, it could be something as simple as updating the query and use a macro to get a query string you put in a link.

0 votesVote for this answer Mark as a Correct answer

Jason Ortman answered on May 18, 2017 21:01

Thank you.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.