> ## Documentation Index
> Fetch the complete documentation index at: https://fuse-docs.swovo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DateTime Columns

> How to add a datetime column to your importer through code.

You can add a column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.

The DateTime column type validates that values are a specific DateTime format.

## addColumn Function

The `addColumn` function accepts an object as an argument.

* `internal_key` (String) - required: The internal key used to access a column's value.
* `label` (String) - required: The user-facing column label that is shown in the interface.
* `column_type` (String) - required: Should be "datetime".
* `required` (String) - required: Whether or not the column is required.
* `pattern` (String) - required: must be one of [these patterns](#patterns).
* `position` (Optional): The position or order of the column.
* `unique` (Optional): Whether values should be unique.
* `validations` (Optional): An array of built-in data validations. See [Built-in DateTime Validations](#built-in-date-validations).
* `transformations` (Optional): An array of built-in data transformations. See [Built-in DateTime Transformations](#built-in-date-validations).

### Example Code

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
      const importer = new FuseImporter();

      importer.getSessionToken = ... // see https://fuse-docs.flatirons.com/getting-started/sessions

      const validations = [
        {
          validation_type: "before_date",
          message: "Must be before 01/01/2023"
          options: {
            before_date: "2023-01-01T00:00:00.000Z"
          }
        }
      ];

      const transformations = [
        {
          transformation_type: "autoformat",
        }
      ];

      importer.addColumn({
        internal_key: "datetime",
        label: "Date and Time",
        column_type: "datetime",
        pattern: "MM/dd/yyyy HH:mm:ss",
        required: true,
        position: 1,
        unique: true,
        validations: validations,
        transformations: transformations
      });

      importer.show();
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
      const importer = new FuseImporter();

      importer.getSessionToken = ... // see https://fuse-docs.flatirons.com/getting-started/sessions

      // ColumnValidations should be imported from "fuse-importer"
      const validations: ColumnValidations<"datetime">[] = [
        {
          validation_type: "before_date",
          message: "Must be before 01/01/2023",
          options: {
            before_date: "2023-01-01T00:00:00.000Z",
          },
        },
      ];

      // ColumnTransformations should be imported from "fuse-importer"
      const transformations: ColumnTransformations<"datetime">[] = [
        {
          transformation_type: "autoformat",
        },
      ];

      importer.addColumn({
        internal_key: "datetime",
        label: "Date and Time",
        column_type: "datetime",
        pattern: "MM/dd/yyyy HH:mm:ss",
        required: true,
        position: 1,
        unique: true,
        validations: validations,
        transformations: transformations,
      });

      importer.show();
    ```
  </Tab>
</Tabs>

## Patterns

**MM/dd/yyyy HH:mm**<br />
Example: 08/31/2023 12:30; 09/31/2005 12:30

**MM/dd/yyyy HH:mm:ss**<br />
Example: 08/31/2023 12:30:45; 08/31/2005 12:30:45

**MM/dd/yyyy HH:mm:ss.SSS**<br />
Example: 08/31/2023 12:30:45.500; 08/31/2005 12:30:45.500

**MM/dd/yyyy h:mm a**<br />
Example: 08/31/2023 1:30 PM; 08/31/2023 1:30 PM

**MM/dd/yyyy h:mm:ss a**<br />
Example: 08/31/2023 1:30:45 PM; 08/31/2005 1:30:45 PM

**MMM dd HH:mm:ss yyyy**<br />
Example: Jan 15 00:34:59 1990; Feb 15 00:34:59 1990

**dd MMM HH:mm:ss yyyy**<br />
Example: 15 Jan 00:34:59 1990; 15 Feb 00:34:59 1990

**MM/dd/yyyy h:mm:ss.SSS a**<br />
Example: 08/31/2023 1:30:45.500 PM; 06/11/2030 1:30:45.500 PM

**MMMM dd, yyyy HH:mm**<br />
Example: August 31, 2023 12:30; January 15, 2023 12:30

**MMMM dd, yyyy HH:mm:ss**<br />
Example: August 31, 2023 12:30:45; January 15, 2023 12:30:45

**MMMM dd, yyyy h:mm a**<br />
Example: August 31, 2023 1:30 PM; January 15, 2023 1:30 PM

**MMMM dd, yyyy h:mm:ss a**<br />
Example: August 31, 2023 1:30:45 PM; January 15, 2023 1:30:45 PM

**MMMM dd, yyyy h:mm:ss.SSS a**<br />
Example: August 31, 2023 1:30:45.500 PM; January 15, 2023 1:30:45.500 PM

**MM-dd-yy HH:mm**<br />
Example: 01-15-90 10:10; 05-15-90 10:10

**dd-MM-yyyy HH:mm**<br />
Example: 15-01-1990 10:10; 15-01-1990 10:10

**dd/MM/yyyy HH:mm**<br />
Example: 15/01/1990 10:10; 12/11/1990 10:10

**dd-MM-yyyy h:mm a**<br />
Example: 15-01-1990 10:10 AM; 15-01-1990 10:10 AM

**dd/MM/yyyy h:mm a**<br />
Example: 12/11/1990 10:10 AM; 15/01/1990 10:10 AM

**MM/dd/yy HH:mm**<br />
Example: 01/15/90 10:10; 05/15/90 10:10

**MM/dd/yy HH:mm:ss**<br />
Example: 01/15/90 10:10:14; 05/15/90 10:10:14

**MM/dd/yy h:mm:ss a**<br />
Example: 01/15/90 5:10:14 AM; 05/15/90 5:10:14 AM

**yyyy/MM/dd HH:mm**<br />
Example: 1990/01/15 10:10; 2007/11/16 10:10

**MM-dd-yyyy HH:mm**<br />
Example: 01-15-1990 10:10; 05-15-1990 10:10

**yyyy-MM-dd HH:mm**<br />
Example: 1990-01-15 10:10; 2007-11-16 10:10

**yyyy-MM-dd'T'HH:mm:ss.SSSZ**<br />
Example: 1990-01-15T00:34:55.020+09:30; 2007-11-16T00:34:55.020+09:30

**yyyy-MM-dd'T'HH:mm:ss.SSS**<br />
Example: 1990-01-15T00:34:55.020; 2007-11-16T00:34:55.020

**yyyy-MM-dd'T'HH:mmZ**<br />
Example: 1990-01-15T10:10+09:30; 2007-11-16T10:10+09:30

**yyyy-MM-dd'T'HH:mm**<br />
Example: 1990-01-15T10:10; 2007-11-16T10:10

**dd/MM/yyyy**<br />
Example: 25/04/2023; 15/11/2023

## Built-in DateTime Validations

The options property of `addColumn` accepts an array of validations. Each validation has three properties:

* `validation_type:` the name of the validation
* `message:` the message showed to the end user if the validation fails
* `options:` options for the specific validation type

The validations property accepts an array of objects that contains these possible values: `validation_type`, `message` and `options`. As the example below:

##

```javascript theme={null}
validations: [
  {
    validation_type: "before_date",
    message: "Must be before 01/01/2023"
    options: {
      before_date: "2023-01-01T00:00:00.000Z"
    }
  }
]
```

### before\_date

Specifies that the value must be before a certain date.

```javascript theme={null}
validations: [
  {
    validation_type: "before_date",
    message: "Must be before 01/01/2023"
    options: {
      before_date: "2023-01-01T00:00:00.000Z"
    }
  }
]
```

### after\_date

Specifies that the value must be after a certain date.

```javascript theme={null}
validations: [
  {
    validation_type: "after_date",
    message: "Must be after 01/01/2023",
    options: {
      after_date: "2023-01-01T00:00:00.000Z",
    },
  },
];
```

### unique\_case\_sensitive

Specifies that the value must be unique using case-sensitive comparison.

```javascript theme={null}
validations: [
  {
    validation_type: "unique_case_sensitive",
    message: "Must be unique (case sensitive)",
  },
];
```

### unique\_case\_insensitive

Specifies that the value must be unique using case-insensitive comparison.

```javascript theme={null}
validations: [
  {
    validation_type: "unique_case_insensitive",
    message: "Must be unique (case insensitive)",
  },
];
```

## Built-in DateTime Transformations

The options property of `addColumn` accepts an array of transformations. For the datetime transformations, you can specify one property:

* `transformation_type:` the name of the transformation

The transformations property accepts an array of objects that contains these possible values: `transformation_type`. As the example below:

```javascript theme={null}
transformations: [
  {
    transformation_type: "autoformat",
  },
];
```

### autoformat

The autoformat transformation automatically transforms the date in the column to a standardized format specified by the `pattern` on the column.

```javascript theme={null}
transformations: [
  {
    transformation_type: "autoformat",
  },
];
```
