Hi all, I am trying to convert a number into a dat...
# gooddata-platform
e
Hi all, I am trying to convert a number into a date and can’t seem to find the right function to do this with. Essentially, I have a metric that is (date) + number and the output is a number. Thanks in advance!
j
Hi @Emily Ward, result of MAQL formula is always a number. Ordinal number of date is used when this expression is being evaluated. I am not sure what is the use case. Consider extension of your model by additional date dimension with the shifted date and apply the transformation in output stage (e,g. using a database view).
e
Hi there, here is a bit more explanation on the use case: -I have a date, Project Creation, and I am adding 4 (days) to this to calculate the SLA timeline for allocation of a project. When this metric is calculated it returns the ordinal number of a date, but I am trying to convert this back to a date so that the data is digestable.
j
The best solution is to compute the SLA timeline prior to loading data into GD platform and display it as date attribute rather than metric. Workaround can be to use attributes like “Day of Month”, “Month” and “Year” and use some complex formula to add 4 days and get the result in form of number with format MMDDYYYY (e,g, 03082022 for March 8, 2022) and then use metric formatting to display it as 03/08/2022. Note that formula needs to be complex because each month has different number of days. Maybe you may consider to use some formulas from https://en.wikipedia.org/wiki/Julian_day or https://en.wikipedia.org/wiki/Ordinal_date to extract day and month components from ordinal number of date.