How can you save a date in sharepoint programatically?
I have a list with a date field and want to save a date into that field and a regular DateTime field isnt working.
How can you save a date in sharepoint programatically?
I have a list with a date field and want to save a date into that field and a regular DateTime field isnt working.
You should be able to save a standard .NET DateTime object into a SPFieldDateTime, like so:
using (SPSite site = new SPSite("http://YOUR URL"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["news"];
SPListItem item = list.Items.Add();
DateTime dt = DateTime.Now;
item["Title"] = "Test";
item["Expires"] = dt;
item.Update();
}
}