SharePoint All Day Event gives obscure result
Asked Answered
G

1

2

I'm using the following code to create an All Day Event in a SharePoint calendar:

newitem = listobject.Items.Add()
guid = System.Guid.NewGuid()
            newitem["Name"] = "All Day Event " + guid.ToString()
            newitem["Title"] = "All Day Event " + guid.ToString()
            newitem["Start Time"] = System.DateTime.Now.Date
            newitem["End Time"] = System.DateTime.Now.Date
            newitem["Description"] = "Created by Automation Script"
            newitem["Location"] = "Location " + guid.ToString()
            newitem["UID"] = guid
            newitem["All Day Event"] = 1
            newitem.Update()
            print newitem["Created"]

However, when I query for the Created date of the created item (as in the last line ), it gives me the time in UTC. But in case of a Normal event or a recurrent event it gives me the local time. I tried to find the Kind property of the DateTime object, but it is set to Unspecified. The same problem occurs even if an All Day Event is created through the SharePoint site (manually). So I came to a conclusion that there is nothing wrong in the code. Please help me.

Graces answered 14/9, 2009 at 14:2 Comment(3)
@Prabhu: When reformatting wasn't sure if your code was C# or something else. Please edit if it's not correct.Manufacture
Also not sure why the sharepoint-designer tag is there.Manufacture
@Prabhu: OK restored your original formattingManufacture
F
1

See

SO SharePoint - all day events behave differently in CAML query

Flyer answered 5/10, 2009 at 18:1 Comment(1)
Thanks Ryan.. That gave me a great reliefGraces

© 2022 - 2024 — McMap. All rights reserved.