web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to compare fixed t...
Power Automate
Suggested Answer

How to compare fixed time in if condition

(0) ShareShare
ReportReport
Posted on by
Hi, 
I want to check if time is greater than 10.30amCST then it should trigger an email ..here time will be in CST 
 
How to compare with this specific format of time is my query  in power automate desktop 
I have the same question (0)
  • Suggested answer
    NsL Coder Profile Picture
    475 Super User 2025 Season 2 on at
    There are a few ways you can compare time, assuming you have a dynamic content of time_to_compare_converted_to_cst and it is in normal data time format that has all parts of date time. 2024-07-01T11:31:32.000
     
    one simple way is to concat the hour minute seconds in a 24-hr clock manner and do string comparison.
     
    formatDateTime(time_to_compare_converted_to_cst , 'HHmmss')
    greater than '103000'
  • Suggested answer
    VishnuReddy1997 Profile Picture
    2,656 Super User 2025 Season 2 on at
    Hey Hi,
     
    Please find the solution.
     
     
     
    Code:
    Please copy this code to the flow and make necessary changes.
    @@copilotGeneratedAction: 'True'
    Scripting.RunVBScript.RunVBScript VBScriptCode: $'''\' This code has been generated by AI. Original prompt:
    \' Vbscript to convert system cureent data and time to CST
    Dim objShell, objWMIService, colTimeZones, objTimeZone, localDateTime, cstDateTime
    
    \' Create shell object
    Set objShell = CreateObject(\"WScript.Shell\")
    
    \' Get the current system date and time
    localDateTime = Now
    
    \' Get WMI service
    Set objWMIService = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")
    
    \' Get the time zone information
    Set colTimeZones = objWMIService.ExecQuery(\"SELECT * FROM Win32_TimeZone\")
    
    \' Loop through the time zones to find the current time zone bias
    For Each objTimeZone in colTimeZones
        \' Calculate the CST time by subtracting the bias (in minutes) from the local time
        \' CST is UTC-6, so we need to add 6 hours (360 minutes) to the bias
        cstDateTime = DateAdd(\"n\", objTimeZone.Bias + 360, localDateTime)
        Exit For
    Next
    
    \' Output the CST date and time
    WScript.Echo cstDateTime''' ScriptOutput=> CSTDateandTime ScriptError=> ScriptError
    Text.SplitText.Split Text: CSTDateandTime StandardDelimiter: Text.StandardDelimiter.Space DelimiterTimes: 1 Result=> CST_Time
    SET Time TO CST_Time[1]
    LOOP WHILE (True) = (True)
        IF Time > $'''10:30:00''' THEN
            EXIT LOOP
        END
        @@copilotGeneratedAction: 'True'
    Scripting.RunVBScript.RunVBScript VBScriptCode: $'''\' This code has been generated by AI. Original prompt:
    \' Vbscript to convert system cureent data and time to CST
    Dim objShell, objWMIService, colTimeZones, objTimeZone, localDateTime, cstDateTime
    
    \' Create shell object
    Set objShell = CreateObject(\"WScript.Shell\")
    
    \' Get the current system date and time
    localDateTime = Now
    
    \' Get WMI service
    Set objWMIService = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")
    
    \' Get the time zone information
    Set colTimeZones = objWMIService.ExecQuery(\"SELECT * FROM Win32_TimeZone\")
    
    \' Loop through the time zones to find the current time zone bias
    For Each objTimeZone in colTimeZones
        \' Calculate the CST time by subtracting the bias (in minutes) from the local time
        \' CST is UTC-6, so we need to add 6 hours (360 minutes) to the bias
        cstDateTime = DateAdd(\"n\", objTimeZone.Bias + 360, localDateTime)
        Exit For
    Next
    
    \' Output the CST date and time
    WScript.Echo cstDateTime''' ScriptOutput=> CSTDateandTime ScriptError=> ScriptError
        Text.SplitText.Split Text: CSTDateandTime StandardDelimiter: Text.StandardDelimiter.Space DelimiterTimes: 1 Result=> CST_Time
        SET Time TO CST_Time[1]
    END
    Outlook.Launch Instance=> OutlookInstance
    Outlook.SendEmailThroughOutlook.SendEmail Instance: OutlookInstance Account: $'''Varikutivishnu@acme.com''' SendTo: $'''jnarsin@tcs.com''' Subject: $'''Test''' Body: $'''Hi,
    
    Test,
    
    Regards,
    RPA''' IsBodyHtml: False IsDraft: False
    
     
     
     
    (Note:- if you got your solution you can mark as solution and gives kudos)
     

    Thanks & Regards
    Vishnu Reddy
     
  • Suggested answer
    Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at
     
    for dates, i would always recommend subtract logic, like subtract one date from another date and find the difference in terms on days/months/seconds etc. like take below example
     
    if d1 equal to 2024-12-14 10:30CST and d2 equal to 2024-12-14 11:30CST, then difference b/w d1-d2 is will be negative which means d2 is ahead of d1. 
     
    Use subtract from dates action for the finding difference b/w dates in power automate desktop
    Thanks & Regards,
    Nived N 
    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

     Found my answer helpful? Please consider marking it as the solution!
     Your appreciation keeps me motivated. Thank you!
     
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard