Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lee 1130 posts 3088 karma points
    Jul 13, 2010 @ 11:29
    Lee
    0

    Create Document With Specific Create Date?

    Is it possible to set the createdate to be a specific day using

    Document doc = Document.MakeNew("My new document", dt, author, 1018); 

    Basically I am importing some data and need the create date to reflect the original/previous create date, so that the date folders are created correctly.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 13, 2010 @ 11:36
    Lee Kelleher
    1

    Hi Lee,

    Yes, you should be able to set the CreateDate property, i.e.

    doc.CreateDate = DateTime.Parse("2009-12-31");

    Cheers, Lee.

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jul 13, 2010 @ 11:37
    Peter Dijksterhuis
    1

    Yes, that's possible.

    doc.CreateDateTime = DateTime.Parse(yourdatetime);

    HTH,

    Peter

  • Lee 1130 posts 3088 karma points
    Jul 13, 2010 @ 11:38
    Lee
    0

    Ok cool, I'm going to give it a go now :)  I shall reward you some more karma if it works ;)

    Cheers bud

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 13, 2010 @ 11:39
    Lee Kelleher
    0

    Sorry, Peter is correct, the property is "CreateDateTime" ... ignore my typo! (I was doing it off the top of my head) ;-)

    Cheers, Lee.

  • Pavel Gurecki 55 posts 158 karma points
    Apr 24, 2013 @ 16:17
    Pavel Gurecki
    1

    Bringing 3 year old thread to ask same question for the new v6 API.

     Creating content node with ContentService, setting the CreateDate property and publishing it seems to reset the CreateDate.

    Here's the code:

    IContent node = service.CreateContent(Name, parentNode, typeAlias);

    node.CreateDate = PublishDate; //is of type DateTime 

    service.SaveAndPublish(node); 

    While debugging node.CreateDate is set as it should, but after publishing node creation date is reseted.

    Any ideas how to make this work with v6 API?

    EDIT:

    It seems that CreateDate is resetted on first save and publish, you need to set date after initial save & publish and do that one more time.

    Working code:

    IContent node = service.CreateContent(Name, parentNode, typeAlias);

    service.SaveAndPublish(node); //initial save&publish

    node.CreateDate = PublishDate; //is of type DateTime 

    service.SaveAndPublish(node); 

     

Please Sign in or register to post replies

Write your reply to:

Draft