cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Date formatting

Harsha3
New Contributor III

Hi ,

I am trying to convert a local-date-time format to dd-MMM-yy ( say for eg :13-NOV-19).
I tried various methods still could not achieve this . It could be useful if I have a method to achieve this

Thanks in advance

image

11 REPLIES 11

mmussitsch
New Contributor II

Sorry to raise this up again, but this is the only example I could find that might be the same thing Iโ€™m running into.
Can someone explain to me why a field with local-date-time is coming in as a json with a Timestamp key as shown below? Then when I try to build an expression to parse out only what I need, the result is correct, but running preview continually returns โ€œnullโ€. Or if null-safe access is off it will give me an error like it canโ€™t evaluate .Timestamp.
image

Hi Mellisa,

Good day, I think there is no method .toString for Date object type, you can try Date.parse($LAST_DDD.timestamp).toLocaleDateString({โ€˜formatโ€™:โ€˜yyyy-MM-ddโ€™})

Thanks,
EmEm

mmussitsch
New Contributor II

Thank you for the response.
Unfortunately, even trying to reference โ€œ.timestampโ€ of any kind, I get an error that it canโ€™t be evaluated. Now itโ€™s in the hands of snaplogic support. As an ugly workaround, the formatting of .timestamp can be left alone and instead write the entire results to a file/json and then read back in and manipulated, but we shouldnโ€™t have to do that.

Seems like that you need to provide the current format of the timestamp for the Date.parse to workโ€ฆ

image

Date.parse($IF_ROW_PROCESSED_DT.Timestamp,โ€œyyyy-MM-ddโ€™Tโ€™HH:mm:ss.SSSโ€™+0000โ€™โ€).toLocaleDateString({โ€œformatโ€:โ€œdd-MMM-yyโ€}).toUpperCase()

mmussitsch
New Contributor II

Well according to support, the snowflake Timestamp_NTZ is not compatible with snaplogic expression language. Only work around is to use a string field instead if possibe. If not in the database, then write it out to a file without manipulation and then read it in as a string in snaplogic. Not ideal, but I think candidate for snaplogic enhancement request.

Thanks again for the help.