> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Date and Time Functions

> This article describes all date and time functions on the YiDA platform and how to use them, including calculating date ranges and converting timestamps into date objects. It also explains the basic concepts of the date component.

This article lists all date and time functions in YiDA, along with the issues you may encounter when using them.

## Function Overview

| **Function**                                         | **Description**                                                                                                                                                                              |
| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [CASCADEDATEINTERVAL](/yida/form/py2n7nkaimvsypoe)   | Calculates the number of days between the start and end dates in a date range picker component.                                                                                              |
| [CASCADEDATEINTERVALV2](/yida/form/blbqwhbcsa44h4tb) | Returns the number of days between two dates in a date range.                                                                                                                                |
| [DATE](/yida/form/pxp74275bikx0xvt)                  | Converts a timestamp into a date object.                                                                                                                                                     |
| [DATEDELTA](/yida/form/tz0uzryeft12rpgw)             | Adds or subtracts a specified number of days to or from a given date.                                                                                                                        |
| [DAY](/yida/form/zblyusnwcvrbregn)                   | Returns the day of the month of a date.                                                                                                                                                      |
| [DAYBEGIN](/yida/form/kuda7hpn6ru4mv2g)              | Returns the timestamp of a specified date component with hours, minutes, and seconds set to zero.                                                                                            |
| [DAYEND](/yida/form/me7p9i2f32erci85)                | Returns the timestamp of a specified date component with hours, minutes, and seconds set to their maximum values.                                                                            |
| [DAYS](/yida/form/acp1c60wvm7v5g5m)                  | Returns the number of days between two dates.                                                                                                                                                |
| [DAYS360](/yida/form/wa3hg2rs7i40eb90)               | Returns the number of days between two dates based on a 360-day year.                                                                                                                        |
| [HOUR](/yida/form/ly60vx00lfm5mp2r)                  | Returns the hour of a date.                                                                                                                                                                  |
| [ISOWEEKNUM](/yida/form/bn3zv56eunro0tzd)            | Returns the week number of a specified date within the year.                                                                                                                                 |
| [MINUTE](/yida/form/vgvc4f7myfwpbqa5)                | Returns the minute of a date.                                                                                                                                                                |
| [MONTH](/yida/form/obwipf12ew36n32a)                 | Returns the month of a date.                                                                                                                                                                 |
| [NETWORKDAYS](/yida/form/qfwh5ivncnfg57wt)           | Calculates the number of working days between two specific dates.                                                                                                                            |
| [NOW](/yida/form/qn4qo0ydlb2i1iz1)                   | Returns the current time. Equivalent to the TODAY function.                                                                                                                                  |
| [SECOND](/yida/form/qpvcqng3gb14aww7)                | Returns the second of a date.                                                                                                                                                                |
| [SYSTIME](/yida/form/enkgisafnaalmkl0)               | Returns the current server time.                                                                                                                                                             |
| [TIME](/yida/form/zl268y77wk9nhwkg)                  | Returns the decimal number for a specific time.                                                                                                                                              |
| [TIMESTAMP](/yida/form/bmgm5sirz825ncal)             | Converts a date object into a timestamp. It is mainly used to convert a date object produced by a date formula into a timestamp and assign the value to a date component.                    |
| [TODAY](/yida/form/vzgyog2mozwazdrk)                 | Returns today's date.                                                                                                                                                                        |
| [WEEKNUM](/yida/form/kn045dietny22f9k)               | Returns the week number of a specific date.                                                                                                                                                  |
| [WORKDAY](/yida/form/cwczglfr7liddmmw)               | Calculates the date that falls N working days after a specific date. Weekends are excluded from working days by default, and you can define holidays to specify working days more precisely. |
| [YEAR](/yida/form/ghx7avaatnrt3gow)                  | Returns the year of a date.                                                                                                                                                                  |
| [YEARBEGIN](/yida/form/whagovdhgkyy0n4k)             | Returns the first date of the year in which a date falls.                                                                                                                                    |
| [YEAREND](/yida/form/vyck0fpn0a1kp2ty)               | Returns the last date of the year in which a date falls.                                                                                                                                     |

## Basic Concepts

The **date component** returns a **timestamp** in milliseconds.

The following two basic concepts relate to date functions:

* Timestamp: A timestamp is a format that computers use to record time. It is usually a character sequence that uniquely identifies a moment in time. In YiDA forms, the date component stores time as such a sequence.
* Date object: A date object represents the year, month, day, hour, minute, and second. Its format is Sat Aug 01 2015 00:00:00 GMT+0800 (China Standard Time), which corresponds to 00:00:00 on August 1, 2015, Beijing time. Date objects support various operations, such as date addition and subtraction.

In YiDA, letters are commonly used to represent date formats. The following table lists the meaning of each letter.

| **Letter** | **Meaning**          |
| ---------- | -------------------- |
| G          | Era designator       |
| y          | Year                 |
| M          | Month                |
| d          | Day                  |
| h          | Hour in AM/PM (1–12) |
| H          | Hour in day (0–23)   |
| m          | Minute               |
| s          | Second               |
| S          | Millisecond          |
| E          | Day of week          |
| D          | Day of year          |
| F          | Day of week in month |
| w          | Week of year         |
| W          | Week of month        |
| a          | AM/PM marker         |
| k          | Hour in day (1–24)   |
| K          | Hour in AM/PM (0–11) |
| z          | Time Zone            |

For example, use the pattern string `yyyy-MM-dd HH:mm:ss:S E D F w W z` to format the current time as the Default of the **Formatted Date** text component. Define the formula as follows:

The page displays as follows:

## FAQ

* Q1: How do I use a formula to get the current date?

A: Open the form designer page. The page already contains a date component. Select it, choose **Formula Edit** from the Default drop-down list on the right, and then click the blue **Edit Formula** button below.

Click to build the complete formula: `TIMESTAMP(NOW())`. Click **Confirm**, and then click **Save** in the upper-right corner of the page designer.

**Q: How do I automatically get the contract end date?**

A: Follow these steps to configure the contract end date.

1. Add two date components to the form and name them Start Date and End Date.
2. Add two Numerical components and name them Contract Term and Leap Year Adjustment.

<Steps>
  <Step title="Step 1">
    Because leap years and common years differ, contract duration is usually calculated based on a common year (365 days). Handle this with a formula in advance. To keep the form clean, hide this field and set its data to Always submit. The detailed formula configuration is shown below:
  </Step>

  <Step title="After you enter the contract start time and contract term, the contract end time is calculated automatically. Configure the formula as follows" />
</Steps>

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DATEDELTA(DATE(DATEDELTA(DATE(Start Date),365*Contract Term)),-1+Leap Year Adjustment)
```

4. Result
