Regular expression with dates and hours


I want to get the hour and minute from Sprint Start Date (from 2020-04-07 09:06:54 get 09:06). Tried to create the calculated member:
[Sprint].CurrentMember.Get(‘Start date’) MATCHES “((?:[0-1][0-9]|2[0-3]):[0-5][0-9])”, but receive the error in the fields:
#ERR: Exception while executing function MATCHES: java.lang.ClassCastException

How can I solve it?

Hi Anton,

The MATCHES function throws an error when it tries to compare the regex to an empty value (NULL). Or it might be that you are trying to regex a date format value with .Get()

NOT IsEmpty([Sprint].CurrentMember.GetString("Start date"))
[Sprint].CurrentMember.GetString("Start date") MATCHES "((?:[0-1][0-9]|2[0-3]):[0-5][0-9])"

Please note that MATCHES function would just return true/false anyway.
There might be better ways to get the hour and minute, like adding a separate field in JIRA, that is then imported into eazyBI as a new property. But if you want to go the string extraction way then you can use Left() and Right() functions.

Right([Sprint].CurrentMember.GetString("Start date"), 8)

Left([Measures].[Last 8 symbols], 5)

Screenshot of the result below.

I hope that helps!
Gvido Neilands,

1 Like