
# Pivot date type

In Pivot, one date field can be configured as year, half year, quarter, month, week of year, week of month, day, and hour.

#### Date type

When you click the Apply button, the pivot screen is reorganized based on the selected date.

<GridView demo='pivotguides/05-pivotDatetime/01' height={700}/>

```js
var typeValue = $("#typeList").val();
if (typeValue == "type1") {
     pivot.setPivotFields({
       columns: ["Year of sale"],
       rows: ["Country","Brand Name"],
       values: [{
           name: "Vehicle price",
           expression: "sum"
       }, {
           name: "Sales Quantity",
           expression: "sum"
       }]
   });
}else if(typeValue == "type2"){
   pivot.setPivotFields({
       columns: ["Year of sale","Quarter of sale"],
       rows: ["Country","Brand Name"],
       values: [{
           name: "Vehicle price",
           expression: "sum"
       }, {
           name: "Sales Quantity",
           expression: "sum"
       }]
   });
}else if(typeValue == "type3"){
   pivot.setPivotFields({
       columns: ["Year of sale","Quarter of sale","Month of sale"],
       rows: ["Country","Brand Name"],
       values: [{
           name: "Vehicle price",
           expression: "sum"
       }, {
           name: "Sales Quantity",
           expression: "sum"
       }]
   });
}else if(typeValue == "type4"){
   pivot.setPivotFields({
       columns: ["Year of sale","Month of sale","Week of sale"],
       rows: ["Country","Brand Name"],
       values: [{
           name: "Vehicle price",
           expression: "sum"
       }, {
           name: "Sales Quantity",
           expression: "sum"
       }]
   });
}
```

#### Date Format

You can specify the date format yourself and set it to be displayed in the label value.

<GridView demo='pivotguides/05-pivotDatetime/02' height={700}/>

```js
{
     name: "Sale date",
     fieldHeader: "Sale Date",
     sourceField: "Sale Date",
     dateType: "custom",
     dateFormat:"yyyy-MM-dd"
}
```