AppAlloy Documentation
Home
  • Glossary
  • 🚀Getting Started
    • Introduce AppAlloy Documentation
    • Build your first AppAlloy app
    • From sheet to app
  • 🗃️Data management
    • Learn data structure
    • Set up data source
      • Integrate with Google Sheets
      • Integrate with Microsoft Excel
      • Build Alloy table
      • Upload local file
    • Manage data type
    • Ultimate guide for data sheet
  • ⚒️Manage table views
    • Design Record View
    • Design Actions
      • Update current record
      • Delete current record
      • Delete many records
      • Create record
      • Open external URL
      • HTTP Request
      • Open phone call popup
      • Open SMS Popup
      • Open email popup
      • Send notification
    • Design Record Components
      • Plain Text
      • Phone number
      • Email
      • URL
      • Map
      • Barcode
      • Checkbox
      • Number
      • Currency
      • Rating
      • Voting
      • Date time
      • Relative date
      • Count Down / Count Up
      • Single Photo
      • Photo Gallery
      • Carousel
      • Audio Player
      • Video Player
      • Youtube Player
      • Vimeo Player
    • Design Form View
    • Design Form fields (synced tables)
      • Text (for synced tables)
      • Number (for synced tables)
      • Date time (for synced tables)
      • Checkbox (for synced table)
      • Options (for synced table)
      • Photos (for synced table)
      • Files (for synced table)
      • Table lookup (for synced table)
      • Signature (for synced table)
    • Design Form fields (Alloy tables)
      • Single line Text (for Alloy table)
      • Long Text (for Alloy table)
      • Phone number (for Alloy table)
      • Email (for Alloy table)
      • Barcode (for Alloy table)
      • Number (for Alloy table)
      • Currency (for Alloy table)
      • Checkbox (for Alloy table)
      • Date (for Alloy table)
      • Photos (for Alloy table)
      • Files (for Alloy table)
      • Single select (for Alloy table)
      • Multiple select (for Alloy table)
      • Address (for Alloy table)
      • Table lookup (for Alloy table)
  • 🎨Manage pages
    • Manage page types
    • Design 'View From' Page
    • Page Layouts
      • List Layout
      • Grid Layout
      • Card Layout
      • Map Layout
      • Checklist Layout
      • Calendar Layout
      • Kanban Layout
    • Design Canvas View Page
    • Canvas Charts
      • Line chart
      • Area Chart
      • Pie Chart
      • Donut Chart
      • Column chart vs. Stacked Column chart
      • Bar chart vs. Stacked bar chart
      • Table
    • Design Form of... Page
  • ⚙️Manage workflow
    • Introduce Workflow
    • Design a workflow
  • 🔌Manage Integration
    • Manage AppAlloy Integration
    • Manage Slack Integration
    • Manage Gmail Integration
    • Manage Google Drive Integration
    • Manage Google Calendar integration
  • 📱Manage App Settings
    • Manage app appearance
  • 🌎App distribution
    • Publish your app
    • Use app as Mobile Web app
    • Use app on AppAlloy Air
  • 🚹Account, team, and plan
    • Manage Account
    • Manage Apps
    • Manage Users
    • Manage Plans
    • Manage Teams
  • #️⃣Learn Power FX
    • Introduce Power FX
    • Operators & Identifiers
    • Formula References
      • Average
      • Concatenate
      • Date
      • DateAdd
      • DateDiff
      • DateValue
      • DateTimeValue
      • Day
      • If
      • Month
      • Now
      • Rand
      • RandBetween
      • Round
      • RoundDown
      • RoundUp
      • Sum
      • Text
      • Today
      • Weeknum
      • Weekday
      • Year
Powered by GitBook
On this page
  • Syntax
  • The complete syntax
  • Example
  • Table
  • Requirement
  • Formula
  • Result

Was this helpful?

  1. Learn Power FX
  2. Formula References

DateAdd

add or subtract a specified number of days, months, quarters, or years to a date.

The DateAdd function in Power FX is used to add or subtract a specified number of days, months, quarters, or years to a date. This function is useful when you need to calculate future or past dates based on a starting point.

Syntax

The basic syntax is:

DateAdd(ThisItem.DateTimeColumn, AddedValue, TimeUnit.[Unit])

However, your DateTime data in the Alloy table is always ISO 8601 formatted. Therefore, you need to use the DateValue() or DateTimeValue() function to convert an ISO 8601 formatted date string to a valid date type that Power FX can work with.

Then, the syntax will be:

  • If the data includes Date only

DateAdd(DateValue(ThisItem.DateTimeColumn), AddedValue, TimeUnit.[Unit])
  • If the data includes Date and Time

DateAdd(DateTimeValue(ThisItem.DateTimeColumn), AddedValue, TimeUnit.[Unit])

The result will be formatted as Date(year, month, day). To covert it back to 8601 ISO format use Text().

The complete syntax

  • If the data includes Date only

Text(DateAdd(DateValue(ThisItem.DateTimeColumn), AddedValue, TimeUnit.[Unit]),"yyyy-MM-dd")
  • If the data includes Date and Time

Text(DateAdd(DateTimeValue(ThisItem.DateTimeColumn), AddedValue, TimeUnit.[Unit]),"yyyy-MM-dd hh:mm:ss")

In which:

ThisItem.DateTimeColumn: Column of Date Time data for the start date

AddedValue: Number, in Units, to add to the DateTimeColumnYou can use a negative number to subtract time.

TimeUnit.[Unit] - Optional. The type of Units to subtract or add including TimeUnit.Milliseconds, TimeUnit.Seconds, TimeUnit.Minutes, TimeUnit.Hours, TimeUnit.Days, TimeUnit.Months, TimeUnit.Quarters, or TimeUnit.Years. If not specified, TimeUnit.Days are used.

Example

Table

You have a table to track your tasks with columns StartDate and Duration(days).

Requirement

Calculate the Expected End Date = Start Date + Expected Duration (Days)

Formula

Text(DateAdd(DateValue(ThisItem.StartDate), ThisItem.'Duration(days)', TimeUnit.Days),"yyyy-MM-dd")

Result

If the formula and data are correct, you can see the value of the column when you set it to view it in the app.

Last updated 7 months ago

Was this helpful?

#️⃣