AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 27.03.2024, 11:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
crmtipoftheday: Tip #1452: Compare dates in Power Automate
Источник: https://crmtipoftheday.com/1452/comp...power-automate
==============

tl;dr

Always use formatDateTime(), substring(), convertFromUtc(), convertTimeZone() to drop the time part and ensure the dates are in the same timezone.

!tl;dr

The datetime isn’t of any special type in Power Automate; it’s just a string representation of a timestamp in an ISO format. Yes, the format is sortable, so in theory, you could compare just the values. However, if you have a date input parameter in your flow, it comes as a date without any time part, so you might miss that birthday when comparing it to utcNow()!

To further complicate matters, datetime values include both the time portion and a timezone indicator. What is today for you can be yesterday or tomorrow for other people. Time difference can be up to 25 hours (don’t get me started on that Samoa vs American Samoa trip again). And do you really want to compare seconds if you’re after just the date?

Life becomes much easier if you follow two rules:
  1. Bring timestamps into the same timezone.
  2. Extract and compare just the date portion.
The following functions come to the rescue (yes, I am aware there are actions doing the same thing).
  • formatDateTime(date, 'yyyy-MM-dd') – just the date portion
  • substring(datetime, 0, 10) – just the date portion
  • convertFromUtc(datetime, 'Samoa Standard Time‘, ‘yyyy-MM-dd’) – if your user in +13 timezone
  • convertTimeZone(datetime, 'UTC-11', 'Samoa Standard Time', 'yyyy-MM-dd') – convert American Samoa date prior to comparing to the date in Samoa (be very surprised)
Timezones always do my head in (would it be so hard to make them an enumeration?!). Here’s the current list: Default Time Zones | Microsoft Learn. Perhaps I should create a Code only Connector (CoC) for it, so I don’t have to remember the list?

The post Tip #1452: Compare dates in Power Automate appeared first on Power Platform & Dynamics CRM Tip Of The Day.



Источник: https://crmtipoftheday.com/1452/comp...power-automate
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crmtipoftheday: Tip #1451: Aggregates in Power Automate Blog bot Dynamics CRM: Blogs 0 26.03.2024 03:40
crmtipoftheday: Tip #1427: Single letter custom formats for dates in Power Automate cloud flows Blog bot Dynamics CRM: Blogs 0 24.02.2022 19:12
crminthefield: Dynamics 365 and Power Platform Monthly Update-September 2021 Blog bot Dynamics CRM: Blogs 0 11.09.2021 09:04
crminthefield: Dynamics 365 and Power Platform Monthly Update-August 2021 Blog bot Dynamics CRM: Blogs 0 12.08.2021 06:20
crminthefield: Dynamics 365 and Power Platform Monthly Update-July 2021 Blog bot Dynamics CRM: Blogs 0 14.07.2021 02:22

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 20:22.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.