3 weeks ago
How can I parse a string in an object to Date?
eg. Date.parse($vendorBill.tranDate, "dd-MM-YYYY") gives me NaN
How would I parse this correctly to return the date in the $vendorBill.string object please?
3 weeks ago - last edited 3 weeks ago
Hi @AvaniAnand ,
How does the value $vendorBill look like? is it an epoch number or already a value that looks like a date?
I played around with these https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1439344/Date+Functions+and+Properties , when testing/parsing dates
Regards
2 weeks ago
@AvaniAnand - I will guess that the date you are trying to parse is coming from a database - likely DB2. Some databases don't return the date object as expected to SnapLogic and causes confusion when trying to process the data. My recommendation is to format the date as a string in your query (e.g. TO_CHAR(dateval, 'YYYY-MM-DD') as dateval). Then if you need to manipulate the date in SnapLogic, you can use Date.parse() then apply your value changes.
Hope this helps!
a week ago - last edited a week ago
What is the format of $vendorBill.tranDate?
If format is "01-Jan-2025" then this will be Date.parse($vendorBill.tranDate, "dd-MMM-yyyy")
If format is "2025-01-31" then this will be Date.parse($vendorBill.tranDate, "yyyy-MM-dd")
Hope this helps.