Date & Time Adjustments & Calculations

This page demonstrates Hashtag Contexts for Date & Time values.  
Note:  Hashtag Markup is shown below <# in bold #>.   The value generated by processing the Hashtag Markup, and applying any Variable Contexts, is injected into this HTML page after the ⇒ symbol.  
Processing this Hashtag Markup:
<#
// calculate time difference in hours
set start to "09/19/2013 8:30 AM";
set end to "09/19/2013 6:30 PM";
set difference to <#[end as timestamp]#> - <#[start as timestamp]#>;
// difference value should be 10:00:00
#>
<#[difference as timespan "h:mm:ss"]#> ⇒ 10:00:00
Processing this Hashtag Markup:
<#
// adjust minutes using 'minute' or 'minutes'
set time to "09/19/2013 8:00 AM";
set adjusted to <#[time as timestamp + 12 minutes]#>;
// adjusted value should be 09/19/2013 8:12 AM
#>
<#[adjusted as date "M/D/Y h:mm A"]#> ⇒ 09/19/2013 8:12 AM
<#[time as timestamp + 12 minutes as date "M/D/Y h:mm A"]#> ⇒ 09/19/2013 8:12 AM

Processing this Hashtag Markup:
<#
// adjust hours using 'hour' or 'hours'
set time to "09/19/2013 8:00 AM";
set adjusted to <#[time as timestamp + 2 hours]#>;
// adjusted value should be 09/19/2013 10:00 AM
#>
<#[adjusted as date "M/D/Y h:mm A"]#> ⇒ 09/19/2013 10:00 AM
<#[time as timestamp + 2 hours as date "M/D/Y h:mm A"]#> ⇒ 09/19/2013 10:00 AM

Processing this Hashtag Markup:
<#
// adjust days using 'day' or 'days'
set time to "09/19/2013 8:00 AM";
set adjusted to <#[time as timestamp + 12 days]#>;
// adjusted value should be 10/01/2013 8:00 AM
#>
<#[adjusted as date "M/D/Y h:mm A"]#> ⇒ 10/01/2013 8:00 AM
<#[time as timestamp + 12 days as date "M/D/Y h:mm A"]#> ⇒ 10/01/2013 8:00 AM

Processing this Hashtag Markup:
<#
// adjust weeks using 'week' or 'weeks'
set time to "09/19/2013 8:00 AM";
set adjusted to <#[time as timestamp + 2 weeks]#>;
// adjusted value should be 10/03/2013 8:00 AM
#>
<#[adjusted as date "M/D/Y h:mm A"]#> ⇒ 10/03/2013 8:00 AM
<#[time as timestamp + 2 weeks as date "M/D/Y h:mm A"]#> ⇒ 10/03/2013 8:00 AM

Processing this Hashtag Markup:
<#
// adjust months using 'month' or 'months'
set time to "01/31/2013 8:00 AM";
set adjusted to <#[time as timestamp + 13 months]#>;
// adjusted value should be 02/28/2014 8:00 AM
#>
<#[adjusted as date "M/D/Y h:mm A"]#> ⇒ 02/28/2014 8:00 AM
<#[time as timestamp + 13 months as date "M/D/Y h:mm A"]#> ⇒ 02/28/2014 8:00 AM

Processing this Hashtag Markup:
<#
// adjust months using 'month' or 'months'
set time to "04/30/2013 8:00 AM";
set adjusted to <#[time as timestamp + 1 month]#>;
// adjusted value should be 05/30/2013 8:00 AM
#>
<#[adjusted as date "M/D/Y h:mm A"]#> ⇒ 05/30/2013 8:00 AM
<#[time as timestamp + 1 month as date "M/D/Y h:mm A"]#> ⇒ 05/30/2013 8:00 AM

Processing this Hashtag Markup:
<#
// adjust end of months using 'monthend', 'monthends', 'monthsend', 'monthsends'
set time to "04/30/2013 8:00 AM";
set adjusted to <#[time as timestamp + 1 monthend]#>;
// adjusted value should be 05/31/2013 8:00 AM
#>
<#[adjusted as date "M/D/Y h:mm A"]#> ⇒ 05/31/2013 8:00 AM
<#[time as timestamp + 1 monthend as date "M/D/Y h:mm A"]#> ⇒ 05/31/2013 8:00 AM

Processing this Hashtag Markup:
<#
// adjust end of months using 'monthend', 'monthends', 'monthsend', 'monthsends'
set time to "02/28/2014 8:00 AM";
set adjusted to <#[time as timestamp + 24 monthends]#>;
// adjusted value should be 02/29/2016 8:00 AM
#>
<#[adjusted as date "M/D/Y h:mm A"]#> ⇒ 02/29/2016 8:00 AM
<#[time as timestamp + 24 monthends as date "M/D/Y h:mm A"]#> ⇒ 02/29/2016 8:00 AM

Processing this Hashtag Markup:
<#
// adjust end of months using 'monthend', 'monthends', 'monthsend', 'monthsends'
set time to "01/17/2016 7:43 AM";
set adjusted to <#[time as timestamp + 1 monthend]#>;
// adjusted value should be 02/29/2016 7:43 AM
#>
<#[adjusted as date "M/D/Y h:mm A"]#> ⇒ 02/29/2016 7:43 AM
<#[time as timestamp + 1 monthend as date "M/D/Y h:mm A"]#> ⇒ 02/29/2016 7:43 AM

Processing this Hashtag Markup:
<#
// adjust first of months using 'firstofmonth', 'firstsofmonth', 'firstofmonths', 'firstsofmonths'
set time to "01/31/2013 8:00 AM";
set adjusted to <#[time as timestamp + 1 firstofmonth]#>;
// adjusted value should be 02/01/2013 8:00 AM
#>
<#[adjusted as date "M/D/Y h:mm A"]#> ⇒ 02/01/2013 8:00 AM
<#[time as timestamp + 1 firstofmonth as date "M/D/Y h:mm A"]#> ⇒ 02/01/2013 8:00 AM

Processing this Hashtag Markup:
<#
// adjust years using 'year' or 'years'
set time to "02/29/2012 8:00 AM";
set adjusted to <#[time as timestamp + 3 years]#>;
// adjusted value should be 02/28/2015 8:00 AM
#>
<#[adjusted as date "M/D/Y h:mm A"]#> ⇒ 02/28/2015 8:00 AM
<#[time as timestamp + 3 years as date "M/D/Y h:mm A"]#> ⇒ 02/28/2015 8:00 AM


The Hashtag Markup Language provides Contexts for reformatting Variable values.  

The examples in this section cover the many Contexts the Hashtag Framework supports to alter Variable values.