Skip to content

Latest commit

 

History

History
87 lines (69 loc) · 1.88 KB

random-datetime.mdx

File metadata and controls

87 lines (69 loc) · 1.88 KB
sidebar_position sidebar_label
7
Random Datetime

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

Random Datetime

:::tip Goal Write mask rule logic to

  • generate random datetimes from an interval defined by <from> and <to> properties
  • The random-datetime function generates values having format yyyy-MM-dd HH:mm:ss (Database Timestamp format)
    • "%1$tF %1$tT"

:::

Ano Structure and Examples

<Tabs defaultValue="structure" values={[ { label: 'Structure', value: 'structure' }, { label: 'Update Example', value: 'update' }, { label: 'Create Example', value: 'create' }, ]}

        ...
        mask <column> <rule-name>
            format "%1$tF %1$tT"
            random-datetime <from> <to>      // [<from>, <to>]
        ...
table birth_certificate
    ...
    column datetime created
    ...
...
task ... {
	  update birth_certificate
  		mask created
		    	format "%1$tF %1$tT"
			    random-datetime 2020-01-01 07:00:00 2020-01-15 23:59:59
      ...
}
table birth_certificate
    ...
    column datetime created
    ...
...
task ... {
	  create birth_certificate minimum-rows 50
  		mask created
		    	format "%1$tF %1$tT"
			    random-datetime 2020-01-01 07:00:00 2020-01-15 23:59:59
      ...
}
  • <from> and <to> values are included in the generated values.
    • Both are written using the format yyyy-MM-dd HH:mm:ss (Database Timestamp format)
  • random-datetime creates values of the format yyyy-MM-dd HH:mm:ss, the "%1$tF %1$tT" will result in strings of this format.
        For different formats, see Formats
  • Note the lack of double quotes " around the values after the random-datetime keyword. This is the correct syntax.