Skip to main content
Question

PQL/SQL Convert Date

  • April 10, 2024
  • 8 replies
  • 33 views

Hello everyone, can you help me please?

 

I need to convert the field "T056P"."DATAB". Solutions can be in either PQL or SQL.

 

But it's not returning anything. I've tried various methods such as: TIMESTAMPADD, ADD_MILLIS, ADD_SECONDS, CAST, TO_DATE, all without success.

 

The return for the first three I mentioned was: Operator requirements are not met. Operator 'ADD_MILLIS' is not compatible with inputs of type DATE and STRING - expected DATE and INT."

8 replies

janpeter.van.d
Level 12
Forum|alt.badge.img+26

Hi @douglas.henri,

 

I'm not sure what format "T056P"."DATAB" has, but in case it is a Unix timestamp ((milli)seconds since Epoch time): I think you are doing good by using the ADD_MILLIS operator.

 

It looks like however your column is formatted as string and not as integer. Therefore you need to convert this, in PQL this would be:

 

ADD_MILLIS({t 0 }, TO_INT("T056P"."DATAB")).

 

Let me know if this works.


  • Author
  • Level 6
  • April 10, 2024

Hi Jan-peter, Thank's for the response, I tested it here and this was my results:

 

 

 

image 

 

imageI don't understand why the date comes in this format (79808971), could it be something specific in this table T

 

tks again for help


dennis.pflug
Level 10
Forum|alt.badge.img+7

Hi Douglas,

 

T056P.DATAB is stored as epoch timestamp.

You can convert it to a timestamp in a similar way as it was / is done with TCURR table which is used for currency conversion e.g.:

 

CAST(RIGHT('00000000'|| CAST((99999999-DATAB) AS VARCHAR(10)),8) || ' ' || '00:00:00' AS DATETIME)

 

2024-04-10_17h50_39 

BR

Dennis


  • Author
  • Level 6
  • April 10, 2024

Hi Douglas,

 

T056P.DATAB is stored as epoch timestamp.

You can convert it to a timestamp in a similar way as it was / is done with TCURR table which is used for currency conversion e.g.:

 

CAST(RIGHT('00000000'|| CAST((99999999-DATAB) AS VARCHAR(10)),8) || ' ' || '00:00:00' AS DATETIME)

 

2024-04-10_17h50_39 

BR

Dennis

Hello Dennis, veryyy thank's, it worked out !

 

Have nice day !

 

 

 

 

image


dennis.pflug
Level 10
Forum|alt.badge.img+7

Perfect.

You're welcome.

Have a great day.


  • Author
  • Level 6
  • April 16, 2024

Hi Dennis,can you clear my doubts?

I needed to take this table to BSEG level, could you tell me how to do this? The only key column is MANDT. It's possible?

In PQL I could BIND it, but I can't to connect it in my model

 

image


dennis.pflug
Level 10
Forum|alt.badge.img+7

Hi douglas,

 

honest answer: I don't know how to link T056P (Reference interest rate) with BSEG.

I am not aware of any direct link by using REFERENCE field from T056P with BSEG.

 

What I can tell you is that using MANDT will not work as you will not have any unique identifier and DM load will crash due to duplicates.

 

BR

Dennis


  • Author
  • Level 6
  • April 19, 2024

Tks for help Dennis