DateTime Add Examples

The following example uses various add[DateTime part] functions, such as AddYears, AddDays, AddHours, etcetera.

Smartsite SXML CopyCode image Copy Code
<table>
<tr><td>AddYear</td><td>{datetime.format(datetime.addyears("2008-02-28 01:00:00",2),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>AddMonths</td><td>{datetime.format(datetime.addmonths("2008-02-28 01:00:00",2),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>AddDays</td><td>{datetime.format(datetime.adddays("2008-02-28 01:00:00",2),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>AddHours</td><td>{datetime.format(datetime.addhours("2008-02-28 01:00:00",2),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>AddMinutes</td><td>{datetime.format(datetime.addminutes("2008-02-28 01:00:00",2),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>AddSeconds</td><td>{datetime.format(datetime.addseconds("2008-02-28 01:00:00",2),"dd-MM-yyyy HH:mm:ss tt")}</td></tr>
<tr><td>AddMilliSeconds</td><td>{datetime.format(datetime.addmilliseconds("2008-02-28 01:00:00",279),"dd-MM-yyyy HH:mm:ss.fff tt")}</td></tr>
</table>
Example Result CopyCode image Copy Code
<table>
<tr><td>AddYear</td><td>28-02-2010 01:00:00 AM</td></tr>
<tr><td>AddMonths</td><td>28-04-2008 01:00:00 AM</td></tr>
<tr><td>AddDays</td><td>01-03-2008 01:00:00 AM</td></tr>
<tr><td>AddHours</td><td>28-02-2008 03:00:00 AM</td></tr>
<tr><td>AddMinutes</td><td>28-02-2008 01:02:00 AM</td></tr>
<tr><td>AddSeconds</td><td>28-02-2008 01:00:02 AM</td></tr>
<tr><td>AddMilliSeconds</td><td>28-02-2008 01:00:00.279 AM</td></tr>
</table>