Home > front end >  Converting Timestamp to Month without the 00:00:00
Converting Timestamp to Month without the 00:00:00

Time:04-28

I have a timestamp that looks like this:

2022-01-23 03:50:48

I want it to look like this:

2022-01-01

However, it currently looks like this:

2022-01-01 00:00:00

My SQL Logic: , DATE_TRUNC('month', DATE(timestamp)) as reporting_month

Is there anyway I can make it look like just the month and the year?

CodePudding user response:

Use date_format to format date value:

select date_format(now(), '%Y-%m-%d')
_col0
2022-04-27

Or cast timestamp to date:

select date(now())
  • Related