I am having an issue with converting an integer date (20180525) to a date in the format of YYYY-MM-DD. Is there a way to do this or should I just convert it in code (Java in this case)? Any help with this would be most appreciated. Thank you!
if your dates are stored as integers with YYYYMMDD, you can pass it to the date function by first casting to TEXT.
SELECT date(20180525::TEXT)
otherwise, use the function to_date with a date formatter:
SELECT to_date(20180525::text, 'YYYYMMDD')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With