--- title: "duration()" slug: "date-substract-2" updated: 2026-08-13T08:35:41Z published: 2026-08-13T08:35:41Z canonical: "docs.lobstersoftware.com/date-substract-2" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # duration() This function returns the duration between two dates **b** and **a** in time unit **c**. ## Parameters | Parameter | Description | | --- | --- | | a | Date | | b | Date | | c | Unit (*y*, *M*, *d*, *h*, *m*, *s*, *S*) | ### Possible units for parameter c | Value | Time unit | | --- | --- | | *milli* or *S* | Milliseconds | | *sec* or *s* | Seconds | | *min* or *m* | Minutes | | *hour* or *H* | Hours | | *day* or *d* | Days | | *month* or *M* | Months | | *year* or *y* | Years | ## Examples | Parameter a | Parameter b | Parameter c | Result | | --- | --- | --- | --- | | 2010-03-01 00:00:00 | 2010-03-15 00:00:00 | d | -14 | | 2010-03-15 00:00:00 | 2010-03-01 00:00:00 | d | 14 | | 2010-03-01 00:00:00 | 2010-03-15 00:00:00 | h | -336 | | 2010-03-15 00:00:00 | 2010-03-01 00:00:00 | h | 336 |