DateTime Set Examples

The following example uses various set[DateTime part] functions, such as SetYear, SetDay, SetHours, etcetera.
Notice that each method returns the original DateTime value, with the specified DateTime part replaced with the given value.

Smartsite SXML CopyCode image Copy Code
<table>
<tr><td>SetYear</td><td>{datetime.format(datetime.setyear("2008-02-28 01:00:00",2003),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>SetMonth</td><td>{datetime.format(datetime.setmonth("2008-02-28 01:00:00",9),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>SetDay</td><td>{datetime.format(datetime.setday("2008-02-28 01:00:00",9),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>SetHours</td><td>{datetime.format(datetime.sethours("2008-02-28 01:00:00",9),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>SetMinutes</td><td>{datetime.format(datetime.setminutes("2008-02-28 01:00:00",9),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>SetSeconds</td><td>{datetime.format(datetime.setseconds("2008-02-28 01:00:00",9),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>SetMilliSeconds</td><td>{datetime.format(datetime.setmilliseconds("2008-02-28 01:00:00",379),"dd-MM-yyyy HH:mm:ss.fff tt")}</td></tr>
<tr><td>SetTime</td><td>{datetime.format(datetime.settime("2008-02-28 01:00:00",13,3,5),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>SetDate</td><td>{datetime.format(datetime.setdate("2008-02-28 01:00:00",2003,12,25),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
</table>
Example Result CopyCode image Copy Code
<table>
<tr><td>SetYear</td><td>28-02-2003 01:00:00 AM</td></tr>
<tr><td>SetMonth</td><td>28-09-2008 01:00:00 AM</td></tr>
<tr><td>SetDay</td><td>09-02-2008 01:00:00 AM</td></tr>
<tr><td>SetHours</td><td>28-02-2008 09:00:00 AM</td></tr>
<tr><td>SetMinutes</td><td>28-02-2008 01:09:00 AM</td></tr>
<tr><td>SetSeconds</td><td>28-02-2008 01:00:09 AM</td></tr>
<tr><td>SetMilliSeconds</td><td>28-02-2008 01:00:00.379 AM</td></tr>
<tr><td>SetTime</td><td>28-02-2008 13:03:05 PM</td></tr>
<tr><td>SetDate</td><td>25-12-2003 01:00:00 AM</td></tr>
</table>