# Period types

{% hint style="info" %}
User permissions: Administration: Period Types, Databases and Sync
{% endhint %}

{% hint style="success" %}
Periods are a core concept in Phocas. Read the [Periods page](https://app.gitbook.com/s/7pj8v25BOyqZTdG5mdD1/getting-started/periods) to learn more about the **Period** menu in Phocas and the different types of periods. See the [Periods (Administration)](https://docs.phocassoftware.com/administration/periods-administration) page for links to related administration pages.
{% endhint %}

Period *types* define the core increments of time that allow users to analyze their data, forming the basis of defined periods.&#x20;

The *default* period types are Year, Month and Day and you cannot edit or delete these. You can, however, edit and delete other period types, known as *custom* period types, such as Quarters or Weeks. You can also add more custom period types as required. This difference in period types is explained in the following image:

* On the left, you can see the **Periods Types** administration page with the list of the custom period types you can manage. You can add more period types to this list.
* On the right, you can see the corresponding list of period types in the database setup (**Date** section in Designer), along with the three default period types (in the green box). It is here in the database setup that you determine the period types that are available in the database.

<figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/G93exTUQanBK7VKQwotD/3239608435.png" alt="" width="653"><figcaption></figcaption></figure>

After you select the period type(s) for a database, you can use them as a foundation for [defined periods](https://docs.phocassoftware.com/administration/databases-administration#set-defined-periods-for-a-database) in that database. These are the periods that display in the **Period** menu in the Analytics and Financial Statements modules.

<div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/khEP4wOoTl2zOVM3r7Ax/3239903323.png" alt="" width="488"><figcaption></figcaption></figure></div>

In the Budgets & Forecasts module, the selected period types for a database become available for selection in the setup of budgets and forecasts.

<figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/hV3Y49KJXVbndL87lKss/image.png" alt=""><figcaption></figcaption></figure>

To manage the period types for your Phocas site, you need the following Administration permissions: **Period Types**, **Databases** and **Sync**.

## Add a period type <a href="#periodtypes-addaperiodtype" id="periodtypes-addaperiodtype"></a>

The process of adding a new period type has two key steps. First, you add the period type, then you define each *moment* in that period, in other words, add the collection of date ranges that make up the period. You can define the moments in three ways; (A) manually enter the moments, (B) import a file containing the moments or (C) base the period type on synced data.

1. Click **Administration** > **Period types**.
2. On the **Period Types** page, click **New**.
3. In the **Period Types** window, enter a name for the new period type, for example, *Quarter*.

   <div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/o1xSjw7kRWKUrYVNr30M/3100574056.png" alt="" width="170"><figcaption></figcaption></figure></div>
4. If you want to base the moments on synced data, select the **Is Sync Period Type** checkbox. Additional options display. Skip to the expandable section (C) below.
5. Click **Save**. The new period type displays in the list on the **Period Types** screen.

   <div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/vYFWdQISKAlsbj4w6H7V/614639.png" alt="" width="170"><figcaption></figcaption></figure></div>
6. Define each *moment* in the period type using one of the methods outlined below (expand the applicable section).

<details>

<summary>A. Manually add moments</summary>

1. On the **Period Types** screen, click the new period type to open its **Moments** screen.

   <div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/36Q9QsNVc5IHhy6MsdMC/614637.png" alt="" width="374"><figcaption></figcaption></figure></div>
2. On the **Moments** screen, click **Add**.
3. Enter a name for the moment (such as Quarter 1) and the date range, then click **Save**.

   <div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/dLoOG2vpUAqyxRewIC1J/616998" alt="" width="170"><figcaption></figcaption></figure></div>

   Note that you cannot enter dates that overlap with an existing period type. If you try to do this, you will get a warning message and have to adjust your dates.&#x20;

   <div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/LQGtawEeWZRjHDUaVY1v/617843" alt="" width="170"><figcaption></figcaption></figure></div>
4. Repeat the above two steps to define the other moments (such as Quarter 2, Quarter 3 and Quarter 4) in the period type.
5. Review all the moments in the period type, then click **Close**.
6. Proceed to add the new period type to the database.

</details>

<details>

<summary>B. Import moments</summary>

1. Prepare a file that contains the moments in the new period type.
   * The file must be a .txt file with the columns Name, Start Date, End Date and Year in that order with no headings, as per the image below.&#x20;
   * The Name must be unique. Although, in reality, there might be a Week 1 every year, you need to name your moments individually. For example, Wk1-2016, Wk1-2017, and so on.
   * Data in the Year column must be 4 numbers only. If your moment spans a change in year, it is recommended you use the year that matches the Start Date.
   * You can download and edit the file used in the example below.

     <div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/XjWa6ISm8ORRhpWt1DEv/616990" alt="" width="204"><figcaption></figcaption></figure></div>
2. On the **Period Types** screen, select the new period type and click **Import**.
3. Upload the file.
4. Set the date format to match that of the imported file (in this example it is dd/mm/yyyy) and click **Upload**.

   <div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/n7bZSwxy0De06C72m2Pd/3101098155.png" alt="" width="204"><figcaption></figcaption></figure></div>
5. Review all the moments in the period type, then click **Close**.
6. Proceed to add the new period type to the database.

</details>

{% file src="<https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/0K8dXhgWBFUClW3pn9As/PeriodTypesExample%20-%20Weeks.txt>" %}

<details>

<summary>C. Add a sync period type</summary>

If you have synced data, you can add a period type based on that data.

Notes about the sync period type:

* When the sync source is updated, the period type is also updated. The moments are purged and then the sync rows are loaded.
* The moments within a period type linked to a sync item can only be edited by re-syncing the item.
* You can import moments from such a sync item against any Period Type that is NOT linked to a sync item. The import overwrites any existing moments against the period type.

Prerequisite: Ensure the synced data item contains the moments in the new period type, organized into four columns in this order:

* Name (text)
* Start (date time)
* End (date time)
* Year (integer)

Continuing from step 3 above, wherein the **Period Types** window you select the **Is Sync Period** checkbox and additional options display:

1. Select the source from the **Sync Source** dropdown list.
2. Select the data item from the **Sync Item** dropdown list.
3. Click **Save**. The moments are added automatically for you.

   <div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/ExzG0E3vWOc3cekgpwn0/3100705210.png" alt="" width="170"><figcaption></figcaption></figure></div>

   <figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/RcrMC9fSsA4hTXj7UexJ/615442.jpeg" alt=""><figcaption></figcaption></figure>
4. Click the new period type to review all the moments, then click **Close**.
5. Proceed to add the new period type to the database.

</details>

## Add a period type to a database

After you add a period type using the steps above, you need to [add that period type to the applicable database(s) in Designer](https://docs.phocassoftware.com/administration/designer/modify-a-database#modifyadatabase-customizeperiodtypes-settheperiodtypesandconfigurethemovingperiodcount), then save and rebuild the database.   &#x20;

## Edit or delete the moments in a period type <a href="#periodtypes-editordeletethemomentsinaperiodtype" id="periodtypes-editordeletethemomentsinaperiodtype"></a>

1. On the **Period Types** page, click the period type to open its **Moments** screen.
2. Take the applicable action:
   * Edit the moment details: Click the moment (blue link), make your changes, and click **Save**.
   * Delete a moment: Select the moment row and click **Delete** > **Yes**.
3. Click **Close**.

## Delete a period type or moment <a href="#periodtypes-deleteaperiodtypeormoment" id="periodtypes-deleteaperiodtypeormoment"></a>

On the **Period Types** page:

* To delete a period type, select the period type row and click **Delete** > **Yes**.
* To delete a moment, click the period type to open its **Moments** screen, then select the moment row and click **Delete** > **Yes**.
