Guide to Power Fx Today Function: Power Apps, PVA, Dataverse
Power Apps
Oct 14, 2023 11:33 PM

Guide to Power Fx Today Function: Power Apps, PVA, Dataverse

by HubSite 365 about Joe Unwin [MVP] (FlowJoe)

Power Platform Lead @ Hitachi | FTRSA, MVP & MCT

Citizen DeveloperPower AppsLearning Selection

Master the crucial Power Fx TODAY function - gain control over dates in Power Apps, PVA, Dataverse.

Easy Guide to Power Fx Today Function - Power Apps, PVA, Dataverse

If you're tired of wrestling with manual date entries or spending time navigating through users' today's dates based on their locations, there's a simple solution. This tutorial is designed to make your life easier by showing you how to use the TODAY function on Power FX.

By understanding and leveraging the TODAY function, it becomes possible to save time and eliminate date-related headaches. Importantly, this function requires updating and is inherently linked to user location. It is explained using the following code:

Today()

Notably, the power platform returns the current date and time, and tests if a date/time value is today. It also provides several functions that work with the local time of the current user. These include:

  • The Now function which provides the current date and time.
  • The IsToday function that reviews if a date/time value is between midnight today and midnight tomorrow.

These functions differ slightly when working with time zone independent values and using Coordinated Universal Time (UTC). The functions UTCNow, UTCToday, and IsUTCToday function similarly but are useful when you don't need to account for the user's local time.

The main caveat for using these functions occur in Microsoft Dataverse for Teams formula columns. During evaluations, they're used sans knowledge of the current user's local time zone, to avoid confusions and inaccuracies.

This article provided you with a comprehensive guide to understanding, using, and applying these functions in the Power platform with the aim to simplify your interactions with date values. As a result, you can save valuable time and reduce common headaches associated with date entries and extractions. For more information, click here to check Microsoft Power platform.

A Closer Look at Power Platform

Microsoft Power platform is a critical tool designed to enhance the productivity of businesses and individuals. By leveraging the interconnected modules of the platform, users can automate business tasks, analyze data, and build virtual agents effortlessly. This is achieved through integral features such as Power FX and its Today function, among others.

The platform revolves around empowering users to understand and utilize local and UTC date/time. It has managed to do this promptly while also allowing for evaluations to occur irrespective of the knowledge of a user's local time zone. This ensures operating efficiency that is both reliable and devoid of timezone-induced errors.

Today, UTCNow, and UTCToday

If you are involved in data manipulation and calculation within a business application context, there is a tool that could seriously boost your productivity. In the realm of Power Apps, Power Virtual Agents, and Microsoft Dataverse, there is a powerful language to facilitate such tasks - Power Fx. A specific function of this scripting language that appeals to many users is the TODAY function. This guide offers a comprehensive walk-through of how this can be utilized efficiently.

So, let's get started. The TODAY function allows you to bypass time-consuming manual date entries and simplifies the process of dealing with user location-based dates. The equation is simple. The less time you spend managing these, the more time you can dedicate to potentially more critical tasks.

But how does it work? The clue is in the name. The TODAY function returns the current date as a date/time value at midnight. This has the same value throughout a day, from midnight today to midnight tomorrow. Also, it works in harmony with the local time of the current user.

For those working with time zone independent values and using Coordinated Universal Time (UTC), similar functions are available - UTCNow, UTCToday, and IsUTCToday. A thing to note here, these formulas are exclusive to Microsoft Dataverse for Teams formula columns and are used only for time-independent fields and values.

  • Now, UTCNow, and UTCToday functions are grouped under volatile functions. Volatile functions return a different value for each evaluation.

  • When used in data flow formulas, the volatile function will only return a different value when the formula is reevaluated.

  • In behavior formulas, these functions will be evaluated each time the behavior formula is evaluated.

These functionalities can be easily tested with simple syntax. For local time usage, you can use Now(), Today(), or IsToday(DateTime). If you prefer to use Coordinated Universal Time (UTC), the formulas to use would be UTCNow(), UTCToday(), or IsUTCToday(TimeZoneIndependentTime).

There are also convenient formulas to retrieve the current date and time and display it as a string, test whether the current date and time is between midnight today and midnight tomorrow, and so much more. For specific needs, customized formulas can also be created.

In context, imagine the current time at 8:58 PM on July 11, 2021, in the Pacific Time Zone (UTC-8), and the language is en-us. With the right formula, you can retrieve the current date and time in the user's time zone, test whether it is between midnight today and midnight tomorrow, adds days to the result, and display them as strings, and much more.

A practical application of these functionalities is to display a clock that updates in real time. You can add a Timer control, set its Duration property to 1000, and its Repeat property to true. You can set the control's OnTimerEnd property to a formula to set the current time as a global variable. Add a Label control, set its Text property to a formula to format the date and time, or just the CurrentTime for hours and minutes but not seconds. This way, you have a real-time clock in your app.

In conclusion, manipulating dates and times in your business apps has never been easier. With functions like TODAY and its variations, your date-related tasks can be accomplished in no time. There's no need to wrestle with manual entries or location-based struggles. With these tools and quick references, enjoy a hassle-free experience building your applications using Power Fx in Power Apps, Power Virtual Agents, and Microsoft Dataverse.

More links on about Power Fx Today Function Guide - Power Apps, PVA, Dataverse

Microsoft Power Fx overview - Power Platform
Feb 22, 2023 — Microsoft Power Fx is the new name for the formula language for canvas apps in Power Apps. This overview and associated articles are a work in ...

Keywords

Power Fx Today Function, Power Apps Guide, PVA Function, Dataverse Guide, Power Platform, Power Fx Function, Microsoft Power Apps, Power Virtual Agents, Power Fx Tutorial, Dataverse in Power Apps