Home  ›  BLOG  ›  2008  ›  5  ›  9
Salsa - Tanzschule Jakob - Nikolas - Di 06.05.08
Freitag, 09. Mai 2008, Christoph Ertl

How to change the creation date of an Umbraco CMS node
Freitag, 09. Mai 2008, Christoph Ertl

This is not a common task, that's why Umbraco doesn't support that directly. But sometimes it's useful to correct the creation date of a page to get consistent data.

In my case I moved old blog entries to my Umbraco blog and created posts out of notes I've taken in the past and wanted them both to occur in a correct timeline.

Ok, here we go:

The node ID

First we must know the id of the node we want to change. There are several ways to accomplish that:

  1. In the Umbraco UI move the mouse over the node you want to change and have a look at the URL displayed in the status bar (Internet Explorer).
    It's javascript:openContent(1111) where 1111 is the id of the node. This also works with the toolbar buttons (save and publish) of the content editor.
    At the end we have to publish this node so this is the preferred way.
  2. The other way is to find the node using an SQL statement. The field text represents the name of the node:
    SELECT * FROM umbracoNode WHERE text = 'nodename'
    To get all nodes where the name starts with the word CMS use the LIKE keyword combined with the wildcard character %.
    SELECT * FROM umbracoNode WHERE text LIKE 'CMS%'

Set the creation date

UPDATE umbracoNode
SET createDate = '20080430 18:00' -- see side note
WHERE id = 1111 -- id as evaluated before

This statement changes the creation date of the node but does not affect the rendering of this node. That's because Umbraco renders nodes using an internal XML structure which is generated while publishing a node.

Publish the Node

Republish the node to ensure that the XML structure is generated.
This task could also be done via an SQL statement, but I prefer using the built in functionality of the CMS.

The node now is rendered as expected.

Side notes

  • Using the ISO format for the date value ensures that the Microsoft SQL server correctly handles the value independent of the culture of the server.
    The ISO format is yyyymmdd hh:mm
  • Don't forget to use the owner of your db in the SQL statement
    e.g. SELECT * FROM owner.umbracoNode