Forum Discussion

amit_saroha's avatar
amit_saroha
New Contributor III
4 years ago

Incorrect date format

Hi,

My requirement is to pass the date as a string “YYYY/MM/DD HH:MI:SS” as a parameter to Oracle procedure snap. I amssusing the expression - Date.now().toLocaleDateString({“format”:“yyyy/MM/dd HH:mm:ss”}).toString()

I can see the correct format in the value but while it is passed as a parameter it always has additional characters as below -

Could you please suggest how I can correct this expression?

11 Replies

  • @amit.saroha

    What are the additional characters that you are getting?

    The first screen date 2022/06/13 11:57:32 looks fine.

    The second one 2022-06-13T12:03:38.000Z has completely different format.

    BR,
    Spiro Taleski

    • amit_saroha's avatar
      amit_saroha
      New Contributor III

      Yes, when it’s passed as a parameter to Oracle Procedure Snap it changed to 2022/06/13 11:57:32 > 2022-06-13T12:03:38.000Z.

      Any way to keep it as 2022/06/13 11:57:32?

  • “Yes, when it’s passed as a parameter to Oracle Procedure Snap it changed to 2022/06/13 11:57:32 > 2022-06-13T12:03:38.000Z.” - this shouldn’t happen.

    From the screen I can see that the date is mapped from input(“$p_processing_date”). It is not taken from parameter.

    If you try to parse the value from parameter as date back, then you will get the “2022-06-13T12:03:38.000Z”.

    So, if you procedure expect the field as date, probably you will need to handle the date conversion and format on procedure level. Otherwise, you can pass the field as string(without parsing back as date), directly from parameter: _p_processing_date

    BR,
    Spiro Taleski

    • amit_saroha's avatar
      amit_saroha
      New Contributor III

      Actually, it’s passed from parameter only, please see below and I couldn’t understand what do you mean by _p_processing_date and where I have to pass it?

      • dmiller's avatar
        dmiller
        Former Employee

        what do you mean by _p_processing_date

        In SnapLogic terminology:

        • when you reference a field, it is prefaced with the dollar sign ($)
        • when you reference a parameter (which is defined in the pipeline properties), it is prefaced with the underscore (_). Parameters are strings.

        So if the p_processing_date was a parameter, you would use _p_processing_date.
        In this case, you are mapping a date to a field.

  • I don’t have a parameter it’s but the current data is generated in the mapper and I am passing it to oracle procedure snap as the parameter.

    Do you think I need to change the date again to the string?

  • toLocaleString() is adding the timezome, same for toUTCString()…you could just add a .split(‘.’)[0] to remove the string value for timezone

    • amit_saroha's avatar
      amit_saroha
      New Contributor III

      Oracle Procedure snap accepts number type parameter so I have to convert it to integer in this snap. This looks like a product bug to me.

      • bojanvelevski's avatar
        bojanvelevski
        Valued Contributor

        You’re using .toLocaleDateString() while passing a DateTime format. Also, you don’t need the .toString() function, the previous one already puts the date into stringified version. Make sure you change that and validate.