DateTime Get Examples
The following example uses various get[DateTime part] functions, such as GetYear, GetDay, GetHours, etcetera.
In every example the 28th of February 2008 has been specified as input datetime.
Therefore, GetDayOfWeek will return 4, since it was a thursday.
GetDayOfYear will return 59, since it was the 59th day of the year.
GetDaysInMonth will result in 29, since february did have 29 days in 2008 (leap year).
Also, because 2008 is a leap year, GetDaysInYear will give 366.
Smartsite SXML | Copy Code |
---|---|
<table> <tr><td>GetDayOfWeek</td><td>{datetime.getdayofweek("2008-02-28")}</td></tr> <tr><td>GetDayOfYear</td><td>{datetime.getdayofyear("2008-02-28")}</td></tr> <tr><td>GetDaysInMonth</td><td>{datetime.getdaysinmonth(2008,2)}</td></tr> <tr><td>GetDaysInYear</td><td>{datetime.getdaysinyear(2008)}</td></tr> <tr><td>GetYear</td><td>{datetime.getyear("2008-02-28")}</td></tr> <tr><td>GetMonth</td><td>{datetime.getmonth("2008-02-28")}</td></tr> <tr><td>GetDay</td><td>{datetime.getday("2008-02-28")}</td></tr> <tr><td>GetHours</td><td>{datetime.gethours("2008-02-28 17:11:13")}</td></tr> <tr><td>GetMinutes</td><td>{datetime.getminutes("2008-02-28 17:11:13")}</td></tr> <tr><td>GetSeconds</td><td>{datetime.getseconds("2008-02-28 17:11:13")}</td></tr> <tr><td>GetMilliSeconds</td><td>{datetime.getmilliseconds("2008-02-28 17:11:13.278")}</td></tr> </table> |
Example Result | Copy Code |
---|---|
<table> <tr><td>GetDayOfWeek</td><td>4</td></tr> <tr><td>GetDayOfYear</td><td>59</td></tr> <tr><td>GetDaysInMonth</td><td>29</td></tr> <tr><td>GetDaysInYear</td><td>366</td></tr> <tr><td>GetYear</td><td>2008</td></tr> <tr><td>GetMonth</td><td>2</td></tr> <tr><td>GetDay</td><td>28</td></tr> <tr><td>GetHours</td><td>17</td></tr> <tr><td>GetMinutes</td><td>11</td></tr> <tr><td>GetSeconds</td><td>13</td></tr> <tr><td>GetMilliSeconds</td><td>278</td></tr> </table> |