<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D50Z00008G7V2NSAVOkta Classic EngineAdministrationAnswered2024-04-16T13:27:50.000Z2018-06-28T09:33:57.000Z2019-04-02T19:58:52.000Z
Can we use okta expression language to do a date or timestamp comparison?
Here's what I'm looking to achieve: I'm trying to create a rule for groups, which looks at a user's join date in the profile and then needs to put them into a group.

So I need to check if a user's join date is less than or equal to the current date and if yes, put them into a group.

The format of joining date (string) in the user profile is like this : "joinDate": "2018-07-03T00:00:00.000Z"

How do I use OKta expression language to compare this string with the current time and then use the result to put the user in a group

 

Gayathri

  • Hello Gayathri,

     

    I would assume that the users have the attribute for join date and of course a value for that. In this case when you add a Group Rule and the expression should look something like this: user.joinDate<="Time.now(EST)"

    I have run a test on my end and was able to make it work.

    In case you have more questions regarding this, don't hesitate to open a ticket with support.

     

    Paul Stiniguta

    Technical Support Engineer

    Okta Global Customer Care

    Expand Post
  • mpbk4 (mpbk4)

    Hi Paul,

    The join date is a custom field created by us on the user profile. The date value is stored as a string. I used the same expression that you suggested but looks like Okta fails to get the comparison right as they both are strings? The rule gives a false positive even when the join date is some time in the future
  • Hello Gayathri,

     

    Since this post has caused confusion among other customers I want to provide a definitive answer regarding this matter.

     

    Time functions are not supported to be used in Group Rules expressions syntax. By adding them between quotes it will indeed return a false positive and that is because it will be treated as an actual string. The function will not be executed. Anything entered between quotes ( "anything" ) will be treated as a string.

     

    As a side-note, Conver.toInt() is also not supported to be used in Group Rules expressions syntax.

     

    Adrian Lazar,

    Technical Support Engineer

    Okta Global Customer Care

    Expand Post
  • 7yybm (7yybm)

    Adrian,

    Are there any other options? I am facing the exact same issue only using the accountExpires value coming from Active Directory. If I were to populate two string values, one for the accountExpires value converted to string (Time.fromWindowsToIso8601(appuser.accountExpires)) and another testToday with todays date/time could I then compare them in a Group Rule to see if one is larger than the other?

    Thanks,

    Rick

     

    Expand Post
  • 7yybm (7yybm)

    I answered my own question:

    user.accountExpires != "1601-01-01T00:00:00.000Z" and user.accountExpires != "30828-09-14T02:48:05.477Z" and user.accountExpires <= user.OktaADImportDate

     

    Mapping on OktaADImportDate = Time.now()

     

    Expand Post
This question is closed.
Loading
Can we use okta expression language to do a date or timestamp comparison?