@@ -522,8 +522,8 @@ provides a convenient shortcut to pass a dimension and a filter as a
522522 operators are used. It requires, for example, that the end date range date
523523 ` 2020-01-01 ` is padded to ` 2020-01-01T23:59:59.999 ` . If only one date is
524524 specified it's equivalent to passing two of the same dates as a date range.
525- You can also pass a string instead of array with relative date range, for
526- example: ` last quarter ` , ` last 360 days ` , or ` next 2 months ` .
525+ You can also pass a string with a [ relative date
526+ range ] [ ref-relative-date-range ] , for example , ` last quarter ` .
527527- ` compareDateRange ` : An array of date ranges to compare a measure change over
528528 previous period
529529- ` granularity ` : A granularity for a time dimension. It supports the following
@@ -562,34 +562,39 @@ const resultSet = cubejsApi.load({
562562// ...
563563```
564564
565- You can also set a relative ` dateRange ` , e.g. ` today ` , ` yesterday ` , ` tomorrow ` ,
566- ` last year ` , ` next month ` , or ` last 6 months ` .
565+ ### <--{"id" : " Time Dimension Format" }--> Relative date range
566+
567+ You can also use a string with a relative date range in the ` dateRange `
568+ property, for example:
567569
568570``` javascript
569571{
570- measures: [' Stories.count' ],
572+ measures: [
573+ ' stories.count'
574+ ],
571575 timeDimensions: [{
572- dimension: ' Stories.time' ,
576+ dimension: ' stories.time' ,
577+ // Relative date range
573578 dateRange: ' last week' ,
574579 granularity: ' day'
575580 }]
576581}
577582```
578583
579- Be aware that e.g. ` Last 7 days ` or ` Next 2 weeks ` do not include the current
580- date. If you need the current date also you can use ` from N days ago to now ` or
581- ` from now to N days from now ` .
584+ Some of supported formats:
582585
583- ``` javascript
584- {
585- measures: [' Stories.count' ],
586- timeDimensions: [{
587- dimension: ' Stories.time' ,
588- dateRange: ' from 6 days ago to now' ,
589- granularity: ' day'
590- }]
591- }
592- ```
586+ - ` today ` , ` yesterday ` , or ` tomorrow `
587+ - ` last year ` , ` last quarter ` , or ` last 360 days `
588+ - ` next month ` or ` last 6 months ` (current date not included)
589+ - ` from 7 days ago to now ` or ` from now to 2 weeks from now ` (current date
590+ included)
591+
592+ <InfoBox >
593+
594+ Cube uses the [ Chrono] [ chrono-website ] library to parse relative dates. Please
595+ refer to its documentation for more examples.
596+
597+ </InfoBox >
593598
594599[ ref-recipe-pagination ] : /recipes/pagination
595600[ ref-client-core-resultset-drilldown] :
@@ -602,3 +607,5 @@ date. If you need the current date also you can use `from N days ago to now` or
602607 /schema/reference/pre-aggregations#parameters-dimensions
603608[ ref-schema-ref-preaggs-time-dimension] :
604609 /schema/reference/pre-aggregations#parameters-time-dimension
610+ [ ref-relative-date-range ] : #relative-date-range
611+ [ chrono-website ] : https://github.com/wanasit/chrono
0 commit comments