SQL Generate full calendar list of dates

I'm trying to generate a list of dates given the current date. For example, for today, March 10, I want the dates from March to be listed. This is for a Calendar application and because of that I need to fill out the calendar with pre and post days. For example, for March, the following dates would need to be included:
02/17/2011
02/28/2011
All the dates in March...AND
04/01/2011
04/02/2011
If you look on a Calendar, it usually starts on a Sunday...depending on where you are. I need all dates returned to account for the extra days before and after the month in question. Do that make sense?
Any help is greatly appreciated.
This is what I would like to see:
Order     DateValue     WeekDay     Day     Month
1     02/27/2011     1     27     2
2     02/28/2011     2     28     2
3     03/01/2011     3     1     3
4     03/02/2011     4     2     3
5     03/03/2011     5     3     3
6     03/04/2011     6     4     3
7     03/05/2011     7     5     3
8     03/06/2011     1     6     3
9     03/07/2011     2     7     3
10     03/08/2011     3     8     3
11     03/09/2011     4     9     3
12     03/10/2011     5     10     3
13     03/11/2011     6     11     3
14     03/12/2011     7     12     3
15     03/13/2011     1     13     3
16     03/14/2011     2     14     3
17     03/15/2011     3     15     3
18     03/16/2011     4     16     3
19     03/17/2011     5     17     3
20     03/18/2011     6     18     3
21     03/19/2011     7     19     3
22     03/20/2011     1     20     3
23     03/21/2011     2     21     3
24     03/22/2011     3     22     3
25     03/23/2011     4     23     3
26     03/24/2011     5     24     3
27     03/25/2011     6     25     3
28     03/26/2011     7     26     3
29     03/27/2011     1     27     3
30     03/28/2011     2     28     3
31     03/29/2011     3     29     3
32     03/30/2011     4     30     3
33     03/31/2011     5     31     3
34     04/01/2011     6     1     4
35     04/02/2011     7     2     4

The problem with your query is that you're not taking account of the week number correctly. For example in 2012 there's a tricky part where it can actually be considered that the calender runs over 54 different weeks...
SQL> break on month skip 1
SQL> set linesize 200
SQL> set pagesize 2000
SQL> column month format a20
SQL> column week format a4
SQL> with req as (select '&Required_Year_YYYY' as yr from dual)
  2      ,offset as (select case when to_char(trunc(to_date(yr,'YYYY'),'YYYY'),'IW') in ('52','53') then 1 else 0 end as offset from req)
  3  select lpad( Month, 20-(20-length(month))/2 ) month,
  4         '('||week||')' as week, "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"
  5  from (
  6    select to_char(dt,'fmMonth YYYY') month,
  7    case when to_char(dt, 'mm') = '12' and to_char(dt,'iw') = '01' and offset = 0 then '53'
  8         when to_char(dt, 'mm') = '12' and to_char(dt,'iw') = '01' and offset = 1 then '54'
  9         when to_char(dt, 'mm') = '01' and to_char(dt,'iw') in ('52','53') then '1'
10         else to_char(to_number(to_char(dt,'iw'))+offset) end as week,
11    max(decode(to_char(dt,'d'),'1',lpad(to_char(dt,'fmdd'),2))) "Mo",
12    max(decode(to_char(dt,'d'),'2',lpad(to_char(dt,'fmdd'),2))) "Tu",
13    max(decode(to_char(dt,'d'),'3',lpad(to_char(dt,'fmdd'),2))) "We",
14    max(decode(to_char(dt,'d'),'4',lpad(to_char(dt,'fmdd'),2))) "Th",
15    max(decode(to_char(dt,'d'),'5',lpad(to_char(dt,'fmdd'),2))) "Fr",
16    max(decode(to_char(dt,'d'),'6',lpad(to_char(dt,'fmdd'),2))) "Sa",
17    max(decode(to_char(dt,'d'),'7',lpad(to_char(dt,'fmdd'),2))) "Su"
18    from ( select trunc(to_date(req.yr,'YYYY'),'y')-1+rownum dt
19           from all_objects, req
20           where rownum <= add_months(trunc(to_date(req.yr,'YYYY'),'y'),12) - trunc(to_date(req.yr,'YYYY'),'y') )
21        ,offset
22    group by to_char(dt,'fmMonth YYYY'),     case when to_char(dt, 'mm') = '12' and to_char(dt,'iw') = '01' and offset = 0 then '53'
23                                                  when to_char(dt, 'mm') = '12' and to_char(dt,'iw') = '01' and offset = 1 then '54'
24                                                  when to_char(dt, 'mm') = '01' and to_char(dt,'iw') in ('52','53') then '1'
25                                                  else to_char(to_number(to_char(dt,'iw'))+offset) end
26    ) x
27  order by to_date( month, 'Month YYYY' ), to_number(x.week)
28  /
Enter value for required_year_yyyy: 2012
old   1: with req as (select '&Required_Year_YYYY' as yr from dual)
new   1: with req as (select '2012' as yr from dual)
MONTH                WEEK Mo Tu We Th Fr Sa Su
    January 2012     (1)                     1
                     (2)   2  3  4  5  6  7  8
                     (3)   9 10 11 12 13 14 15
                     (4)  16 17 18 19 20 21 22
                     (5)  23 24 25 26 27 28 29
                     (6)  30 31
   February 2012     (6)         1  2  3  4  5
                     (7)   6  7  8  9 10 11 12
                     (8)  13 14 15 16 17 18 19
                     (9)  20 21 22 23 24 25 26
                     (10) 27 28 29
     March 2012      (10)           1  2  3  4
                     (11)  5  6  7  8  9 10 11
                     (12) 12 13 14 15 16 17 18
                     (13) 19 20 21 22 23 24 25
                     (14) 26 27 28 29 30 31
     April 2012      (14)                    1
                     (15)  2  3  4  5  6  7  8
                     (16)  9 10 11 12 13 14 15
                     (17) 16 17 18 19 20 21 22
                     (18) 23 24 25 26 27 28 29
                     (19) 30
      May 2012       (19)     1  2  3  4  5  6
                     (20)  7  8  9 10 11 12 13
                     (21) 14 15 16 17 18 19 20
                     (22) 21 22 23 24 25 26 27
                     (23) 28 29 30 31
     June 2012       (23)              1  2  3
                     (24)  4  5  6  7  8  9 10
                     (25) 11 12 13 14 15 16 17
                     (26) 18 19 20 21 22 23 24
                     (27) 25 26 27 28 29 30
     July 2012       (27)                    1
                     (28)  2  3  4  5  6  7  8
                     (29)  9 10 11 12 13 14 15
                     (30) 16 17 18 19 20 21 22
                     (31) 23 24 25 26 27 28 29
                     (32) 30 31
    August 2012      (32)        1  2  3  4  5
                     (33)  6  7  8  9 10 11 12
                     (34) 13 14 15 16 17 18 19
                     (35) 20 21 22 23 24 25 26
                     (36) 27 28 29 30 31
   September 2012    (36)                 1  2
                     (37)  3  4  5  6  7  8  9
                     (38) 10 11 12 13 14 15 16
                     (39) 17 18 19 20 21 22 23
                     (40) 24 25 26 27 28 29 30
    October 2012     (41)  1  2  3  4  5  6  7
                     (42)  8  9 10 11 12 13 14
                     (43) 15 16 17 18 19 20 21
                     (44) 22 23 24 25 26 27 28
                     (45) 29 30 31
   November 2012     (45)           1  2  3  4
                     (46)  5  6  7  8  9 10 11
                     (47) 12 13 14 15 16 17 18
                     (48) 19 20 21 22 23 24 25
                     (49) 26 27 28 29 30
   December 2012     (49)                 1  2
                     (50)  3  4  5  6  7  8  9
                     (51) 10 11 12 13 14 15 16
                     (52) 17 18 19 20 21 22 23
                     (53) 24 25 26 27 28 29 30
                     (54) 31
64 rows selected.
SQL>

Similar Messages

  • IPhone 4s updated with IOS 8. Not the calendar will not show a full list of dates. Instead it shows the whole month with the list of the day selected. I want to have my full list back. So much easier to scroll thru when making appointments.

    iPhone 4s just updated with IOS 8. Now my calendar does not offer the full list of items by day on the screen. Instead I see the month and below the month are the appointments in a list for the selected day only. I would like the option to have the full list available as it is much easier to scroll thru the list when making appointments.

    Hello memormor,
    Thank you for visiting Apple Support Communities.
    To see the full scrollable list of events, start from the day view (tap on a day), not the month view, then click .
    Calendar at a glance - iPhone
    View a list of events. In month view, tap to see a day’s events. In day view, tap .
    Take care,
    Nubz

  • Save a calendar list as a template without data - not all views are getting saved

    I have read plenty of articles showing how to save a list as a template and create a new list from that template. I have a very large calendar list that I want to save as a template. I do not need that data as it is last years. All I want to do is save it
    as a template and create a new list for 2014 using that template.
    Following the process, everything worked fine, but the template that got saved did not save all of the views. I have searched all over for a solution, but no luck. This calendar list has every user as a view, so there are a lot of views created.
    Is there a limit for the number of views in a list that would be saved? How do i create a new calendar with the same views. I do not need that old data.
    Bruno

    SAP support was able to help => Solution is SAP note 1237688.

  • Calendar List view shows entries under the wrong date

    I just upgraded to iOS4 and finding that my calendar entries are appearing under the wrong date in the calendar list view when I am viewing two calendars.
    - List view is ok when viewing 1 calendar
    - Day and Month views are ok at all times (ie: viewing single or multiple calendars)
    - I have 2 Exchange accounts
    - Calendar entries are appearing in the correct order, but under the incorrect date heading.
    - When I intially added the Exchange accounts the calendar list view was fine at first (I could see both calendars correctly in list view) but after a short time later it became screwed up.
    Anyone else experience this?

    Same problem here since my upgrade to iOS4 - but I only noticed today.
    I have 3 calendars set up:
    Gmail (Exchange)
    UK Holidays (iCal)
    Birthdays
    The exchange calendar is always wrong but the other two are correct when my exchange calendar is switched off.
    It has mucked up my scheduling a bit for the next month. I only became suspicious when I noticed the Scottish Bank Holiday Monday at the beginning of August was showing on FRIDAY, 30th of July!

  • SQL function column in drop down list's data provider's query

    Just wondering, if it is somehow possible to use SQL function column for drop down list through data provider.
    At the moment, I am using id column as return value and name as display value from this query through CachedRowSetDataProvider:
    SELECT ALL someTable.Id,
    someTable.Name,
    someTable.Postal_Code,
    FROM someTable
    However, I want to change display to use calculated column as display value, for example Name_PostalCode from below mentioned changed query:
    SELECT ALL someTable.Id,
    CONCAT(someTable.Name, ' - Pin Code: ',someTable.Postal_Code) Name_PostalCode ,
    someTable.Name,
    someTable.Postal_Code,
    FROM someTable
    But JSC doesn't seem to like this.
    Is it someway possible to achieve this?
    Thanks.

    >
    But JSC doesn't seem to like this. Can you explain more. When doesn't it like it, in the design view, in the query editor, when your run it? What is the error you are seeing?
    See http://blogs.sun.com/divas/entry/displaying_multiple_fields_in_a

  • Getting Dates from Calendar List

    If I input year as 2005 and month as Feb, I need to get list of all dates available in that year and month.
    How to get it from Calendar List?

    If I input year as 2005 and month as Feb, I need to
    get list of all dates available in that year and
    month.Calculating the days in the month for the particular year is not difficult. Once that is done, the logic is simple!
    Take a look at http://www.servletsuite.com/jsp.htm. It has some tags I suppose!
    How to get it from Calendar List?Would you be clear on what you really want?

  • How a varaible on date at runtime can bring the list of dates vs.calendar

    Hi All,
    How a varaible on date at runtime can bring the list of dates that already exists the data for vs.calendar?
    Thanks
    - Shashi

    Hi Santosh,
    Now the BI 7.0 has the filter setting as 'Only posted values in InfoProvider' at the infoobject maintenance screen under BEx tab, and that solved the issue.
    Thanks,
    - Shashi

  • I have DELETED calendars showing in my iTunes Sync Calendars list!?

    iMac late 2009
    OSx 10.10.2
    iPhone 6 Plus
    iOS 8.1.3
    Completely Up to Date!
    no clouds involved, no calendar subscriptions.
    I have had a major problem with my Calendar's calendars, which I have completely repaired using Calendar.  During that process, I had to rename a number of calendars in order to keep track of what I was doing - an intermediate diagnostic step.  Once I'd gotten everything right, exported all the "good" calendars to .ics files, and deleted ALL CALENDARS - both the good ones and the intermediately named ones -  then imported the .ics files back into Calendar... leaving me with ONE FULL SET OF CLEAN CALENDAR data.  When I open Calendars on my mac, I see 33 calendars listed on the left side of the window.
    My problem now that I'm ready to put my calendars back onto my phone, is that my Calendars Library (library/calendars) still has many of the intermediate calendar files (that have NOT been DELETED) and in iTunes, the list of Calendars includes all these same intermediate calendars, as well as the new calendars that I want to transfer to my phone.  I would prefer to "select" "ALL CALENDARS" but I can't do that until I can remove the calendars that were supposed to be deleted/removed in the first place.  In other words, I have 33 good, clean Calendars, but there are 71 Calendars in my Calendar Library.
    What are the correct steps to remove the Library/Calendars folder so that the iTunes "Sync Calendars" list only shows the 33 good calendars, and not the 38 unwanted (deleted) calendars.
    What do I have to do to finish the job?

    I have/had the same problem. I tried deleting all the "Library" "Calendar" preference files I could find and like others nothing worked. Like others they would just recreate themselves.
    BUT, I did find the solution. Not sure which part worked, but this is what I did.
    I quit all the apps, Calendar, and iTunes.
    I went into the folder pointed to by job-seeker above:
                   <user>
                   Library
                   Containers
                   com.aple.CalendarAgent
                   Data
                   Library
                   Calendars
    Manually went through each cached calendar folder and looked in the info.plist for the calendar title listed below "<key>Title</key>" and deleted the parent folders of no longer existent calendars.
    Then find an app called "Reminders", open it and you will find all the deleted calendars that you have deleted over the years, they seem to get cached in it, delete them and quit.
    Relaunch iTunes and find the deleted calendars in question are gone.
    I think you could skip all the above and just try deleting the old calendars from this Reminder app and it may work, but the above is what I did when it worked for me and I do not want to recreate the problem just to verify my theory. ;-)
    Hope this helps,
    Michael

  • Calendar list view 7.1.2

    What happened to Calendar List view in 7.1.2.   I used to be able to get List View for ALL dates.   Now I can only get it for ONE DAY! 
    I believe list view worked correctly (i.e. list all days on FULL SCREEN) in 7.1.1.  Only since last update (to 7.1.2) did it get stuck in
    one day only list mode and even that only on the bottom third of the screen on my 5S iPhone. 
    I have seen "instructions" on several forums that "fix" this, but based on the icons they show these were for prior to 7.1.2. 
    Please HELP, and if necessary fix this MASSIVE FLAW in 7.1.2.  I have seen quite a few comments on the other forums I searched tonight of other users that ONLY use Full List Mode.   When searching the list provided is great, would be acceptable fix if Search would let you press search when Search field was empty and therefore "match" on anything. 

    Open calendar and push the area in the oval to show the list view.

  • Getting a list of dates between 2 dates

    Hi All,
    Is there a way I can generate a list of date using a simple SELECT statement to generate all dates between to date points? For example between SYSDATE AND SYSDATE-7?
    One way I know is have a table and run PL/SQL script to put all dates in it and query that but was wondering if it can be achieve via SQL SELECT query at all without creating a table (querying DUAL).
    Cheers.
    Using Oracle XE 11GR2

    Arc_x wrote:
    If I wanted to make both days Inclusive how would I achieve that?Maybe: NOT TESTED!
    select to_date(:start_date,'yyyymmdd') + level - 1 generated_date
      from dual
    connect by level <= to_date(:end_date,'yyyymmdd') - to_date(:start_date,'yyyymmdd') + 1Regards
    Etbin

  • How to use BYDATE to run a procedure on a given list of dates ..?

    Hi all,
    Our client has a meeting schedule and he needs a report prior to every meeting. He had sent us the meeting dates and my manager asked me to schedule a job in the database to run prior to his meeting so that we can get him the report on time. Now I have to schedule a job which should be executed on the dates he has given. I tried to configure the BYDATE parameter in dbms_scheduler.create_schedule but its giving me an error. My database is Oracle 10g R1 and OS is Solaris 9.
    select * from V$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bi
    PL/SQL Release 10.1.0.2.0 - Production
    CORE 10.1.0.2.0 Production
    TNS for Solaris: Version 10.1.0.2.0 - Production
    NLSRTL Version 10.1.0.2.0 - Production
    select PLATFORM_NAME from v$database;
    PLATFORM_NAME
    Solaris[tm] OE (64-bit)
    BEGIN
    dbms_scheduler.create_schedule (
              schedule_name => 'CLIENT_REPORT_JOB',
              repeat_interval => 'FREQ=DAILY;BYDATE=20080912,20080913',
    comments => 'Client Report');
    END;
    ERROR at line 1:
    ORA-27412: repeat interval contains invalid keyword: BYDATE
    ORA-06512: at "SYS.DBMS_ISCHED", line 595
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 1045
    ORA-06512: at line 2
    Can someone help me, please...?
    Thanks in advance.
    Regards,
    FlameThrower

    Hi,
    Many of the Scheduler Calendar enhancements were introduced in 10gR2. Since you are using 10gR1 you should check the Scheduler documentation for 10gR1 to see if BYDATE is supported in that release (I don't think it is).
    If it isn't, as a workaround, you can use a PL/SQL date function which has the list of dates hardcoded in it and returns the next applicable date.
    Hope this helps,
    Ravi.

  • Unable to Read Calendar List Items through CAML

    Hi All,
    * I have created two columns in calendar one Year and other Month.When new event is added in calendar through (Item Added) event receiver I am setting the values to this columns as Name of Month to(February) and Year as(2014)  .So that I can fetch the
    data easily based on month and year
    * Through this Columns Secondly when I try to fetch the data to count number of items of particular month and year using caml query I am getting error as below .
    "Error:One or more field types are not installed properly. Go to the list settings page to delete these fields."
    *My below caml code is working fine if i applied to custom list,But not to calendar.Can any one help me for what reason I am unable to fetch data
    Code
     string year="2014";
     string month="February";
     SPSite mysite = SPContext.Current.Site;
     SPWeb myweb = mysite.OpenWeb();
    SPList mylist = myweb.Lists["Calendar"];
     SPQuery myquery = new SPQuery();
      myquery.Query = @"<Where>
                                          <And>
                                           <Eq>
                                             <FieldRef Name='Year'/>
                                             <Value Type='Text'>" + year + @"</Value>
                                          </Eq>
                                          <Eq>
                                             <FieldRef Name='Month' />
                                             <Value Type='Text'>" + month + @"</Value>
                                          </Eq>
                                         </And>
                                      </Where>";
     SPListItemCollection totaltiems = mylist.GetItems(myquery);
      Label1.Text= "Total Number of Items is "+" "+totaltiems.Count.ToString();
    Thanks, Quality Communication Provides Quality Work. http://siddiq-sharepoint2010.blogspot.in/ Siddiqali Mohammad .

    Hi,
    According to your post, my understanding is that you got an error when read calendar list items using CAML.
    I created two single line of text columns in the Calendar( Year and Month), then add items in the Calendar to check with your code. The CAML query worked well as below.
    string year = "2014";
    string month = "February";
    using (SPSite oSiteCollection = new SPSite("Your site URL"))
    using (SPWeb myweb = oSiteCollection.OpenWeb())
    SPList mylist = myweb.Lists["Calendar"];
    SPQuery myquery = new SPQuery();
    myquery.Query = @"<Where> <And> <Eq> <FieldRef Name='Year'/> <Value Type='text'>" + year
    + "</Value></Eq><Eq>+ "
    + " <FieldRef Name='Month' />+ "
    + " <Value Type='text'>" + month + "</Value>+ "
    + " </Eq> </And></Where>";
    SPListItemCollection totaltiems = mylist.GetItems(myquery);
    Console.WriteLine( "Total Number of Items is " + " " + totaltiems.Count.ToString());
    Console.ReadLine();
    Which type of the two columns in your Calendar? Were they text type?
    Are you sure the field name(<FieldRef Name='Year'/>,
    <FieldRef Name='Month' />) is same as internal name?
    We should only use internal name while refrencing columns in CAML query. If you have space In you column , replace it with "_x0020_", such as
    News_x0020_Category. 
    Thanks & Regards,
    Jason 
    Jason Guo
    TechNet Community Support

  • Get Calendar List Item GUID

    I downloaded code for a reservation event receiver from here: 
    http://blog.sharepointsydney.com.au/post/Setting-up-multiple-calendars-for-meeting-room-bookings-prevent-double-booking.aspx
    However, on the ItemUpdating it throws an "Object Reference Not Set to an Instance of an Object" error.  By commenting out parts of the code and re-deploying I have narrowed the issue down to the line that gets the item's GUID:
    string guid_internal = collItems.List.Fields["GUID"].InternalName;
    When I modify it to something like "UniqueId" I get the "Value does not fall within expected range" error.  Is there a better way to obtain the GUID of the calendar list item - or am I missing something?  Full code below:
    using System;
    using Microsoft.SharePoint;
    namespace Webcoda.WSS.Calendar.Events
    class PreventDoubleBooking: SPItemEventReceiver
    /// <summary>
    /// This event is triggered when the user adds a new item
    /// </summary>
    /// <param name="properties"></param>
    public override void ItemAdding(SPItemEventProperties properties)
    //Our query string variable
    string strQuery = null;
    try
    //Get the Sharepoint site instance
    using (SPWeb oWebsite = new SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl))
    //Get the collection of properties for the Booking item
    SPListItemCollection collItems = oWebsite.Lists[properties.ListTitle].Items;
    //Get the Calendar List that we will be querying against
    SPList calendar = oWebsite.Lists[properties.ListId];
    //Get the internal name of the fields we are querying.
    //These are required for the CAML query
    string start_internal = collItems.List.Fields["Start Time"].InternalName;
    string end_internal = collItems.List.Fields["End Time"].InternalName;
    string MeetingRoom_Internal = collItems.List.Fields["Meeting Room"].InternalName;
    //Get the query string parameters
    string start_str = properties.AfterProperties[start_internal].ToString();
    string end_str = properties.AfterProperties[end_internal].ToString();
    string MeetingRoom_str = properties.AfterProperties[MeetingRoom_Internal].ToString();
    //Construct a CAML query
    SPQuery query = new SPQuery();
    //Create the CAML query string that checks to see if the booking we are attemping
    //to add will overlap any existing bookings
    strQuery = string.Format(@"
    <Where>
    <And>
    <Or>
    <Or>
    <And>
    <Leq>
    <FieldRef Name='EventDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>
    </Leq>
    <Gt>
    <FieldRef Name='EndDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>
    </Gt>
    </And>
    <And>
    <Lt>
    <FieldRef Name='EventDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>
    </Lt>
    <Geq>
    <FieldRef Name='EndDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>
    </Geq>
    </And>
    </Or>
    <Or>
    <And>
    <Leq>
    <FieldRef Name='EventDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>
    </Leq>
    <Geq>
    <FieldRef Name='EndDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>
    </Geq>
    </And>
    <And>
    <Geq>
    <FieldRef Name='EventDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>
    </Geq>
    <Leq>
    <FieldRef Name='EndDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>
    </Leq>
    </And>
    </Or>
    </Or>
    <Eq>
    <FieldRef Name='Meeting_x0020_Room' />
    <Value Type='Choice'>{2}</Value>
    </Eq>
    </And>
    </Where>
    <OrderBy>
    <FieldRef Name='EventDate' />
    </OrderBy>
    ", start_str, end_str, MeetingRoom_str);
    //Set the query string for the SPQuery object
    query.Query = strQuery;
    //Execute the query against the Calendar List
    SPListItemCollection existing_events = calendar.GetItems(query);
    //Check to see if the query returned any overlapping bookings
    if (existing_events.Count > 0)
    //Cancels the ItemAdd action and redirects to error page
    properties.Cancel = true;
    //Edit the error message that will display on the error page
    properties.ErrorMessage += "This booking cannot be made because of one or more bookings in conflict. <BR><BR>";
    //Here you can loop through the results of the query
    //foreach (SPListItem oListItem in existing_events)
    properties.ErrorMessage += "Please go back and schedule a new time.";
    catch (Exception ex)
    //Cancels the ItemAdd action and redirects to error page
    properties.Cancel = true;
    //Edit the error message that will display on the error page
    properties.ErrorMessage = "Error looking for booking conflicts: " + ex.Message;
    /// <summary>
    /// This event is triggered when the user edits an calendar item
    /// </summary>
    /// <param name="properties"></param>
    public override void ItemUpdating(SPItemEventProperties properties) {
    string strQuery = null;
    try {
    //Get the Sharepoint site instance
    using (SPWeb oWebsite = new SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl)) {
    //Get the collection of properties for the Booking item
    SPListItemCollection collItems = oWebsite.Lists[properties.ListTitle].Items;
    //Get the Calendar List that we will be querying against
    SPList calendar = oWebsite.Lists[properties.ListId];
    //Get the internal name of the fields we are querying.
    //These are required for the CAML query
    string start_internal = collItems.List.Fields["Start Time"].InternalName;
    string end_internal = collItems.List.Fields["End Time"].InternalName;
    string MeetingRoom_Internal = collItems.List.Fields["Meeting Room"].InternalName;
    string guid_internal = collItems.List.Fields["GUID"].InternalName;
    //Get the query string parameters
    string start_str = properties.AfterProperties[start_internal].ToString();
    string end_str = properties.AfterProperties[end_internal].ToString();
    string MeetingRoom_str = properties.AfterProperties[MeetingRoom_Internal].ToString();
    string guid_str = properties.AfterProperties[guid_internal].ToString();
    //Construct a CAML query
    SPQuery query = new SPQuery();
    //Create the CAML query string that checks to see if the booking we are attemping
    //to change will overlap any existing bookings, OTHER THAN ITSELF
    strQuery = string.Format(@"
    <Where>
    <And>
    <And>
    <Or>
    <Or>
    <And>
    <Leq>
    <FieldRef Name='EventDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>
    </Leq>
    <Gt>
    <FieldRef Name='EndDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>
    </Gt>
    </And>
    <And>
    <Lt>
    <FieldRef Name='EventDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>
    </Lt>
    <Geq>
    <FieldRef Name='EndDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>
    </Geq>
    </And>
    </Or>
    <Or>
    <And>
    <Leq>
    <FieldRef Name='EventDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>
    </Leq>
    <Geq>
    <FieldRef Name='EndDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>
    </Geq>
    </And>
    <And>
    <Geq>
    <FieldRef Name='EventDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{0}</Value>
    </Geq>
    <Leq>
    <FieldRef Name='EndDate' />
    <Value Type='DateTime' IncludeTimeValue='TRUE'>{1}</Value>
    </Leq>
    </And>
    </Or>
    </Or>
    <Eq>
    <FieldRef Name='Meeting_x0020_Room' />
    <Value Type='Choice'>{2}</Value>
    </Eq>
    </And>
    <Neq>
    <FieldRef Name='GUID' />
    <Value Type='GUID'>{3}</Value>
    </Neq>
    </And>
    </Where>
    <OrderBy>
    <FieldRef Name='EventDate' />
    </OrderBy>
    ", start_str, end_str, MeetingRoom_str, guid_str);
    //Set the query string for the SPQuery object
    query.Query = strQuery;
    //Execute the query against the Calendar List
    SPListItemCollection existing_events = calendar.GetItems(query);
    //Check to see if the query returned any overlapping bookings
    if (existing_events.Count > 0)
    //Cancels the ItemAdd action and redirects to error page
    properties.Cancel = true;
    //Edit the error message that will display on the error page
    properties.ErrorMessage += "This booking cannot be made because of one or more bookings in conflict. <BR><BR>";
    //Here you can loop through the results of the query
    //foreach (SPListItem oListItem in existing_events)
    properties.ErrorMessage += "Please go back and schedule a new time.";
    catch (Exception ex)
    //Cancels the ItemAdd action and redirects to error page
    properties.Cancel = true;
    //Edit the error message that will display on the error page
    properties.ErrorMessage = "Error looking for booking conflicts: " + ex.Message;

    Hi there,
    Please verify the internal name of column which you have hardcoded in the code i.e 
    string start_internal = collItems.List.Fields["Start Time"].InternalName;
    string end_internal = collItems.List.Fields["End Time"].InternalName;
    I have used the Room reservation template from MSDN which has provided by MS under the code name of "Fantastic 40" along with below James Finn article.
    http://www.codeproject.com/Articles/30983/SharePoint-Reservations
    It worked for me for reservation. 

  • How to declare a list of dates

    Hi,
    I have an item which type is "Display as text based on LOV". I put in the source section under the type "Pl/SQL function body" the following pl/sql function :
    DECLARE
    X VARCHAR2 (4000);
    Y DATE ;
    BEGIN
    X := 'SELECT distinct(TO_CHAR(DATE1, ''YYYY'')) d, (TO_CHAR(DATE1, ''YYYY'')) r FROM SIVOA.EVV_'|| :p4_site ||' WHERE CLEF_VAR = (SELECT CLEF_VAR FROM SIVOA.SITE_DEBIT_RIVIERE WHERE SITE ='''|| :p4_site ||''')
    order by d';
    EXECUTE IMMEDIATE X INTO Y;
    RETURN Y ;
    END;The problem is that I get an ORA error.
    ORA-00932: types de données incohérents ; attendu : - ; obtenu : -
    I know that I have declared Y as a date and that what is returned by my function is a list of dates. I don't know how to declare a list of dates or whatever to be returned as a lis of values. Hope I am clear, sorry for my english.
    Thank you for your kind help.
    Christian

    Hi Tony
    You hare very patient with me thank you !!!
    Let me clarify well.
    I am trying to create a list of values based on dates contained in a table. This list of values should contains the "years". If the table contains data for the years 2005, 2006, 2007, then the list of value should return :
    2006
    2007
    2008
    As I want a list of value I need to have a display and a return value. The name of the table is 'dynamic' It is the item P4_SITE that contains a part of the name of the table. This is why I am usins PL/SQL, because I don't know the name of the table in advance.
    I have not seen any way to put a pl/sql statement in the List of values definition of the item. Thi s is why I try to make a LOV with the SOURCE of the item.
    Hope I am clear.

  • ICal and calendar lists in calendar view

    The calendar lists no longer appear in the calendar view of iCal. I was having a problem so deleted ical from the macbook, then did a complete reinstall with an archive and save old settings, THEN updated all the software, THEN deleted the user account that does not show the calendar lists. THEN went to the admin account which has iCal working well with all views and did a reset of my .mac info so that it was/should be just as the correct one was. THEN set up another user account and reloaded the data on inital sync to overwrite data in the new user account. I thought that all these steps should have my calendar lists back BUT not so! Interestingly when i make the calendar list window smaller the scroll bar appears. Any assistance with this will be appreciated

    There is now a new app doing exactly that. ReplyAll app is a new iPhone app which allows to reply to all attendees of a calendar events or forward it to a new invitee as well as replying by SMS to the event organizer. It was created mainly for users who use their iPhone to manage their events. The app was build based on iOS 7 Look and Feel.https://itunes.apple.com/us/app/replyall/id749454893

Maybe you are looking for

  • I've Made the Switch (from iWeb) &amp; Lived to Tell About It.

    I've gotten a lot of help and useful information from this forum over the years and I will certainly miss it. I've just completed a 2 month transition where I've migrated my site from iWeb/Mobile Me to a new site made in RapidWeaver and hosted by Hos

  • Greyed out boxes

    I went back all the way to page 57 of the forums looking for a satisfactory fix to this issue and haven't found one. I checked my file permissions, they are set correctly so that I have full control over the files and folders. The files/folders are N

  • Need help with openDialog

    In the Photoshop script I'm writing, I ask the user to open a file using:      open(File(openDialog())); That works fine. But the user will always be opening an Illustrator (.ai) file. Normally that brings up a dialog box called "Import PDF". But tha

  • How to do changes in Layouts setting and SAP scripts to meet requirment?

    hi SD gurus, Please explain me how create and work with Z output . where and how we do changes in Layouts setting and SAP scripts to meet the user requirments. pls forward func spec of Z output points will be rewarded thanx & regards

  • Watching correlation status in the ABAP stack

    Hi experts, I remember that there was a program or transaction in the ABAP stack of PI  where you can watch the BPM correlation parameters. Does anybody remember wich one? I am unable to find it. Regards Gonzalo