Friday, April 16, 2021

Power Automate: Play With Dates

  1. If The Current Date is 16-April-2021T12:17:10.1808189Z then





  2. Add month to a date (Use addToTime expression)
    1. addToTime(utcNow(),1,'month')
    2. If utcNow() is 16-April-2021T12:17:10.2433164Z then above expression will return 16-May-2021T12:17:10.2433164Z




  3. Jump to 1st day of next month (Use startOfMonth expression)
    1. startOfMonth(addToTime(utcNow(),1,'month'))
    2. If utcNow() is 21-April-2021T12:17:10.2433164Z then above expression will return 01-May-2021T00:00:00.0000000Z




  4. Jump to 1st day of current month (Use startOfMonth expression)
    1. startOfMonth(utcNow())
    2. If utcNow() is 21-April-2021T12:17:10.2433164Z then above expression will return 01-April-2021T00:00:00.0000000Z




  5. Get last date of current month (Use subtractFromTime expression)
    1. subtractFromTime(startOfMonth(addToTime(utcNow(),1,'month')),1,'day')
    2. If utcNow() is 21-April-2021T12:17:10.2433164Z then above expression will return 30-April-2021T00:00:00.0000000Z




  6. Get last date of previous month (Use subtractFromTime expression)
    1. subtractFromTime(startOfMonth(utcNow()),1,'day')
    2. If utcNow() is 21-April-2021T12:17:10.2433164Z then above expression will return 31-March-2021T00:00:00.0000000Z



  7. Get start of today (Use startofDay expression)
    1. startOfDay(utcNow())
    2. If utcNow() is 16-April-2021T18:05:03.1234567Z then above expression will return 16-April-2021T00:00:00.000000Z




  8. Date:- 17-Apr-2021
  9. Get Current Year (Use formatDateTime expression)
    1. formatDateTime(utcNow(),'yyyy')




  10. Get Current Month (Full Name) (Use formatDateTime expression)
    1. formatDateTime(utcNow(),'MMMM')




  11. Get Current Month (Abbreviation) (Use formatDateTime expression)
    1. formatDateTime(utcNow(),'MMM')




  12. Get Current Month (Number) (Use formatDateTime expression)
    1. formatDateTime(utcNow(),'MM')




  13. Get Current Day Of Month (Use formatDateTime expression)
    1. formatDateTime(utcNow(),'dd')




  14. Get Current Day Of Year (Use dayOfYear expression)
    1. dayOfYear(utcNow())
    2. It returns the day of year starting from 1 Jan




  15. Get Day Of Month (Use dayOfMonth expression)
    1. dayOfMonth(utcNow())




  16. Get Day Of Week (Use dayOfWeek expression)
    1. dayOfWeek(utcNow())
    2. It takes Sunday as 0, Monday as 1, Tuesday as 2, Wednesday as 3, Thursday as 4, Friday as 5, Saturday as 6




  17. Get Day Of Week (Name) (Use formatDateTime expression)
    1. formatDateTime(utcNow(),'dddd')




  18. Get First Day Of Week (Complete Date) (Use subtractFromTime with dayOfWeek expression)
    1. subtractFromTime(utcNow(), dayOfWeek(utcNow()), 'Day')




  19. Get First Day Of Week (Name Of Day) (Use formatDateTime with subtractFromTime with dayOfWeek expression)
    1. formatDateTime(subtractFromTime(utcNow(), dayOfWeek(utcNow()), 'Day'), 'dddd')




    2. If you want Monday as 1st day of week, the modify the above expression as any of the below-
      1. formatDateTime(subtractFromTime(addDays(utcNow(), 1), dayOfWeek(utcNow()), 'Day'), 'dddd')
      2. formatDateTime(subtractFromTime(utcNow(), sub(dayOfWeek(utcNow()), 1), 'Day'), 'dddd')
  20. Will add more soon...

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.