Skip to main content

Define a Date

In Decipad, time values are represented with a specific granularity, such as a year, month, day, or a specific time.

Time Granularity

To represent a time value with the granularity of a day, use the date() function:

You can also specify the time value down to the hour:

Or down to the minute:

A time value can have any of the following granularities:

  • Year
  • Month
  • Day
  • Time

Contains

You can check if a certain time value is within another using the contains function:

Time Traveling

You can perform calculations involving time by adding or subtracting time durations to/from a date:

You can also subtract two dates to calculate the time duration between them:

Time Conversions

When working with units of time, different units may have different bases. For example, some years have 365 days, while others have 366. Similarly, some months have 31 days, while others have 30 or 28.

Due to these variations, Decipad cannot directly convert months to weeks. However, you can create custom units by defining the specific number of days in a month:

Alternatively, you can use the average number of days in a month:

It's important to note that when defining units, such as year or month, as a specific number of days, you may encounter limitations in certain conversions. For example, you can't convert a year into a decade because the definition of decade remains unchanged. However, you can still convert a decade into years since the definition of decade is unaffected.