Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Strange problem with date converting

Hello,

Could someone help me to fix the bug in date converting, please?

I've got a set of departure and arrival dates and the delivery-time. The problem is that some dates are in format DD.MM.YYY and some in MM.DD.YYYY.

To make it work correctly i wrote a script like:

Delivery:

LOAD

date(departure) as departure,

date(arrival) as arrival ,

     delivery_time,

    if(arrival-departure=delivery_time,

  Date(arrival),

  if(Date(Date#(arrival, 'MM.DD.YYYY'), 'DD.MM.YYYY') -Date(departure)=delivery_time,

  Date(Date#(arrival, 'MM.DD.YYYY'), 'DD.MM.YYYY'),

  IF(Date(arrival)-Date(Date#(departure, 'MM.DD.YYYY'), 'DD.MM.YYYY') =delivery_time,

  Date(arrival),

  IF(Date(Date#(arrival, 'MM.DD.YYYY'), 'DD.MM.YYYY') -Date(Date#(departure, 'MM.DD.YYYY'), 'DD.MM.YYYY') =delivery_time,

  Date(Date#(arrival, 'MM.DD.YYYY'), 'DD.MM.YYYY'),

  111

   )

   )

  )

  )as arrival1,

if(arrival-departure=delivery_time,

  Date(departure),

  if(Date(Date#(arrival, 'MM.DD.YYYY'), 'DD.MM.YYYY')-Date(departure)=delivery_time,

  Date(departure),

  IF(Date(arrival)-Date(Date#(departure, 'MM.DD.YYYY'), 'DD.MM.YYYY')=delivery_time,

  Date(Date#(departure, 'MM.DD.YYYY'), 'DD.MM.YYYY'),

  IF(Date(Date#(arrival, 'MM.DD.YYYY'), 'DD.MM.YYYY')-Date(Date#(departure, 'MM.DD.YYYY'), 'DD.MM.YYYY')=delivery_time,

  Date(Date#(departure, 'MM.DD.YYYY'), 'DD.MM.YYYY'),

  111

   )

   )

  )

  )as departure1

FROM

(qvd);

but somehow it works on one data-set and doesnt work on another 😃

When I put a text object on the sheet, I see a correct work of conversion, but in the tablebox there is a wrong data=(

Help me please to solve the problem and understand the logic of Qlik=)

Regards,

Alexa

10 Replies
Not applicable
Author

Massimo, thank you very much!!! Your idea works great!!!! "You saved our lifes, we are totally gratefull"

Could you be so kind to tell me (any suggestion about qliks logic in this case),  why my script didnt work, althoug the same code in the text object works good?

Best regards,

Alexa