Forum Discussion

Aleksis's avatar
Aleksis
Regular Visitor
3 years ago
Solved

Changing data type from text to date results in some values being wrong.

Hello,   I'm trying to convert my date which is in text format to the date format, to use for DATEDIFF later on. I want this date to be the same format for all entries (let's say MM/DD/YYYY or 7 O...
  • Aleksis's avatar
    Aleksis
    3 years ago

    Thank you for the help once again. I played around with the formulas and finally came to the following columns and measures. Since Due Day has 4 possible cases, then I just combined the 3 IF statements.

    Due Day = IF( AND(MID([Due Date], 2,1)="/",MID([Due Date], 5,1)= "/"), MID([Due Date],3,2), IF(AND(MID([Due Date],2,1)= "/",MID([Due Date],4,1)= "/"), MID([Due Date],3,1), IF(AND(MID([Due Date],3,1)= "/",MID([Due Date],6,1)= "/"), MID([Due Date],4,2), MID([Due Date],4,1)))
    
    Due Year = RIGHT([Due Date],4)
    
    Due Month = SUBSTITUTE(IF( LEFT([Due Date], 2)="/", LEFT( [Due Date], 1), Left([Due Date],2)),"/","")

     

    The number of days overdue is now showing the correct output with:

    Number of days overdue = DATEDIFF([DueDate_Revised],TODAY(),DAY)

    where

    DueDate_Revised = DATE( [Due Year], [Due Month], [Due Day] )