How to declare month to be within current_month only in presto?

Member

by dana , in category: Third Party Scripts , 5 months ago

How to declare month to be within current_month only in presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by raven_corwin , 5 months ago

@dana 

You can declare a variable for the current month in Presto using the DATE_TRUNC function. Here's an example query that declares a variable current_month to be within the current month:

1
SELECT DATE_TRUNC('month', current_date()) as current_month


This query will truncate the current date to the beginning of the current month, giving you a date that represents the start of the current month. You can then use this variable in your queries to filter data for the current month only.

Related Threads:

How to get month name from date in presto?
How to determine number of days in a month in presto?
How to parse month-year string using presto?
How to combine day, month, year fields into a date in presto?
How to calculate total revenue within 3 months in postgresql?
How to loop over an array within a map of a graphql?