Reputation: 461
XmlNode jobPostDate = xmlDocumentObject.SelectSingleNode("MsgData/HRS_JO_PST_OPN_DT)
var jPdate = jobPostDate.InnerText;
DateTime dt1 = Convert.ToDateTime(jPdate);
var HRS_JO_PST_OPN_DT = dt1;
newItem.Fields[Sitecore.FieldIDs.PublishDate].Value = HRS_JO_PST_OPN_DT.ToString();
I am using the above code to get the date (01/09/2013) and set it to the Publish field, but I am getting '1/1/0001' values, shown in below picture, in the field.
Please advise what I am doing wrong.
Upvotes: 1
Views: 1231
Reputation: 4092
try this to set the value of the date field:
newItem.Publishing.PublishDate = dt1;
Use the Publishing.UnPublishDate
property to set the unpublish date
Upvotes: 5