Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

date_to_string(DateTime | DateOnly, format)

Converts a date to a string.

This function takes a DateTime, DateOnly, or now() as its first argument. For the allowed formats, see the Date Formats section in Date Formats.

Use date_to_string() to display the close date for your opportunities in the format yyyy-MM-dd.. CloseDate must be a DateTime or DateOnly type.

1q = foreach q generate date_to_string('CloseDate', "yyyy-MM-dd") as 'Close Date';

If CloseDate is a Date type, convert it to a DateOnly type with toDate().

1q = foreach q generate date_to_string(toDate('CloseDate', "yyyy-MM-dd"), "yyyy-MM-dd") as 'Close Date';