How to generate a sequence of date and timestamp

About

This how-to shows you how to generate a sequence of date and timestamp with the column sequence generator.

Steps

Creation of the generator file

To generate data, you need to create a generator file that will describe the data to be generated.

The below data resource generator:

  • has the name sequence_time–datagen.yml
  • has the logical name sequence_time
  • will generate 30 values (MaxRecordCount count)
  • has a column named id that has sequence data generator that:
    • starts by default at the value 1
    • increments by default with the value 1
  • has a column named seq_date with the date data type that has sequence data generator
    • with an offset of 10 days in the future from the start date (by default today)
  • has a column named seq_timestamp with the timestamp data type that has sequence data generator
    • starts by default at the value now
    • increments by default with the value 10000 ms (ie 10s)
MaxRecordCount: 30
Columns:
  - name: id
    type: integer
    comment: A id column to see easily the number of values generated
    DataGenerator:
      type: sequence
  - name: seq_date
    type: date
    comment: A column with a sequence date generator
    DataGenerator:
      type: sequence
      start: 2020-11-23
      offset: 10 # the number of day in the future from the start value
      step: 2
  - name: seq_timestamp
    type: timestamp
    comment: A column with a sequence timestamp generator
    DataGenerator:
      type: sequence
      start: 2020-11-23 08:11:10
      step: 10000




Printing the data

With the data print command, we can print the values generated.

tabli data print sequence_time--datagen.yml@howto

howto is the connection that contains the files used in the HowTo's.

id   seq_date     seq_timestamp
--   ----------   ---------------------
 1   2020-12-03   2020-11-23 08:11:10.0
 2   2020-12-05   2020-11-23 08:11:20.0
 3   2020-12-07   2020-11-23 08:11:30.0
 4   2020-12-09   2020-11-23 08:11:40.0
 5   2020-12-11   2020-11-23 08:11:50.0
 6   2020-12-13   2020-11-23 08:12:00.0
 7   2020-12-15   2020-11-23 08:12:10.0
 8   2020-12-17   2020-11-23 08:12:20.0
 9   2020-12-19   2020-11-23 08:12:30.0
10   2020-12-21   2020-11-23 08:12:40.0
11   2020-12-23   2020-11-23 08:12:50.0
12   2020-12-25   2020-11-23 08:13:00.0
13   2020-12-27   2020-11-23 08:13:10.0
14   2020-12-29   2020-11-23 08:13:20.0
15   2020-12-31   2020-11-23 08:13:30.0
16   2021-01-02   2020-11-23 08:13:40.0
17   2021-01-04   2020-11-23 08:13:50.0
18   2021-01-06   2020-11-23 08:14:00.0
19   2021-01-08   2020-11-23 08:14:10.0
20   2021-01-10   2020-11-23 08:14:20.0
21   2021-01-12   2020-11-23 08:14:30.0
22   2021-01-14   2020-11-23 08:14:40.0
23   2021-01-16   2020-11-23 08:14:50.0
24   2021-01-18   2020-11-23 08:15:00.0
25   2021-01-20   2020-11-23 08:15:10.0
26   2021-01-22   2020-11-23 08:15:20.0
27   2021-01-24   2020-11-23 08:15:30.0
28   2021-01-26   2020-11-23 08:15:40.0
29   2021-01-28   2020-11-23 08:15:50.0
30   2021-01-30   2020-11-23 08:16:00.0

Next

Because a generator is just a data resource, you can use it in every data operation.

How to use a generator in a data operation




Related Pages
Undraw Data Processing
Sitemap

A sequence generator is a column data generator that generates a sequence 1,2,3, ... a, b, c, ... 2011-11-10, 2011-11-09, ... blue, red, ... When a tick happens the sequence is going...

Task Runner