Specifying format in FetchSpec


#1

Say I have a typeA which has fieldB. fieldB is of type datetime.

Is it possible to specify a format on top of the returned data in the FetchSpec? For example, I’d like fieldB to be returned in ‘YYYY-MM-DD’ format when fetching typeA?

Something similar to FORMAT in SQL (https://docs.microsoft.com/en-us/sql/t-sql/functions/format-transact-sql?view=sql-server-2017)


#2

the fetch() api just returns data. If you want to adjust data before returning, you shoudl check the “evaluate” api which has a “projection” field. You can use any ExpressionEngineFunction in your format.

c3ShowType(ExpressionEngineFunction) shows the existance of a useful looking function ‘dateTime’

So in this case your query would be:

TypeA.evaluate({projection: "dateTime(fieldB, 'yyyy-MM-dd')"})