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.