0

I have a SharePoint list field called ArchiveDate.

In a C# function I'm looping through the list and have the item in question.

foreach (SPListItem fListItem in fList.Items)     
{      
   foreach (SPField field in fList.Fields)      
    {   

If fListItem[field.Id] has that column item with a date in it. How can I add 7 days to that date using C#?

i know I can set the value of the field to today as follows:

         DateTime dt = DateTime.Now; 
         tListItem["Archive Date"] = dt;
         tListItem.Update();   
Hell.Bent
  • 1,667
  • 9
  • 38
  • 73

1 Answers1

1
DateTime dt = DateTime.Now.AddDays(7); 

or

fListItem[field.Id] = ((DateTime)fListItem[field.Id]).AddDays(7);
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445