Convert TRUNC of a date to DATE_TRUNC

Proprietary

Replaces Oracle's TRUNC of a date with DATE_TRUNC, as PostgreSQL's TRUNC only truncates numbers. Column types are unknown, so a TRUNC is converted only when its format, such as 'MM', or its argument, such as SYSDATE or a TO_DATE call, shows that it truncates a date. Formats that DATE_TRUNC has no unit for, such as 'WW' or 'D', are left as they are.

org.openrewrite.sql.ConvertTruncToDateTrunc
mod run . --recipe=org.openrewrite.sql.ConvertTruncToDateTrunc

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.