Home > Back-end >  Format date results of postgresql query to 'yyyymmdd'
Format date results of postgresql query to 'yyyymmdd'

Time:10-17

I have this code in my postgresql dim_study.created_datetime AS StudyDate,

I need to query results to format to be yyyymmdd.

What is the code I should and use and where should the code be included? Before that line, within that line or after it?

CodePudding user response:

Use to_char to format a timestamp. Pass it the timestamp to be formatted, and the format you want.

to_char(dim_study.created_datetime, 'YYYYMMDD') AS StudyDate

See Data Type Formatting Functions for details.

  • Related