WEEKOF(A,B)
  • 1 Minute to read
  • Dark
    Light
  • PDF

WEEKOF(A,B)

  • Dark
    Light
  • PDF

Article summary

Date Transform: WEEKOF(A,B)

Groups Date B into weekly segments, where first week begins on Date A

Purpose

Use this function to:
  • Group observations into weekly segments, starting on a fixed date
  • Segment data for use in a time-series report, where the reporting interval is in weeks
  • Calculate "Week Commencing" for a date field (W/C)

Return Value

PropertyValue
FieldTypeDate
FieldSize
DataTypeDiscrete
DataSizeShort


Example Return Value: 2019-01-01, 2019-01-08...
Where values are always 7 days apart

Parameters

ParameterJSONDescription
Table“targetTable”: “MyTableName”The target table on which the new field will be created
Filter“dataset”: {DataSet_JSON}Optional.   If a filter is applied, records not in the filter Recordset will be returned as null.
DateTimeFunction“p1”: “WEEKOF(A,B)”WEEKOF(A,B)
A“p2”: “DateTimeFieldName”
“p2”: “DateFieldName”
“p2”: “#YYYY-MM-DD HH:MM:SS”
“p2”: “#YYYY-MM-DD”
Required. The date which provides the first value in the week commencing series
Supports:  
  • DataType: Discrete / Continuous
  • Field Type: Date, DateTime
  • Fixed Value:  #YYYY-MM-DD,    e.g. #2021-04-05
  • Fixed Value:  #YYYY-MM-DD HH:MM:SS,    e.g. #2021-04-05 11:01:08
If A is a date field, the value in A will be used as the first date in the series, and WEEKOF(A,B) will be the closest preceeding week that is a multiple of 7 days after A.

For example:
If A is 2019-01-01,   and B is 2019-01-06,  WEEKOF(A,B) will be 2019-01-01
If A is 2019-01-01,   and B is 2019-01-09,  WEEKOF(A,B) will be 2019-01-08
If A is 2019-02-08,   and B is 2019-02-06,  WEEKOF(A,B) will be 2019-02-01
If A is 2019-02-09,   and B is 2019-02-06,  WEEKOF(A,B) will be 2019-02-02
B“p3”: “DateTimeFieldName”
“p3”: “DateFieldName”
“p3”: “#YYYY-MM-DD HH:MM:SS”
“p3”: “#YYYY-MM-DD”
Required. The date to sort into Weekly segments
Supports:  
  • DataType: Discrete / Continuous
  • Field Type: Date, DateTime
  • Fixed Value:  #YYYY-MM-DD,    e.g. #2021-04-05
  • Fixed Value:  #YYYY-MM-DD HH:MM:SS,    e.g. #2021-04-05 11:01:08

JSON Sample

Usage Notes

Use this function to calculate the date of the beginning of the week for an event or observation.     To specify the day on which the week commences, make sure that parameter A falls on the desired weekday.

See Also:

Example


ExampleDetails
DescriptionGroup into weeks, where first week begins on #201-01-01
Input
  • Table: = [transactions]
  • Function: = DateTransform
  • DateTimeFunction: = WEEKOF(A,B)
  • A:= #2019-01-01
  • B: = [transactions].[date] 
  • Name: =WeekofDate
Sample

Was this article helpful?

What's Next