Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

previous month daate

Hi2023
8 - Asteroid

does anyone know how to pull the previous month date data for a report each time it is run?

 

I am using the SQL Editor in Alteryx

 

 

 

 

DateTimeFormat(CRG_STAT) >= DateTimeFormat(DateTimeAdd(DateTimeNow(), -1, "month"))

 

example I found BUT

 

This one has time inside of it -mine is NOT time just a date.

 

thanks

4 REPLIES 4
CatheyH
8 - Asteroid

Have you tried DateTimeToday()? I set the field as "date" rather than "datetime"

CatheyH_0-1684165722977.png

 

Luke_C
17 - Castor
17 - Castor

Hi @Hi2023 

 

If you're using SQL the Alteryx date syntax won't work. Example SQL syntax:

 

put your field instead of pdate

 

SELECT * FROM  tablename
WHERE pdate >= DATEADD(day,-30,GETDATE()) 
and   pdate <= getdate()

Or use DateDiff

SELECT * FROM  tablename 
WHERE DATEDIFF(day,pdate,GETDATE()) between 0 and 30 

 

vpogaku
6 - Meteoroid

Hi Luke,

 

I have a similar use case where I always want my date field to calculate till previous month end in my YTD calculations.

 

We want our YTD logic to work till end of previous month but should not include current month.

 

For E.g., Even though we don't have current month data (Jan 24) our YTD should work for one prior month of Dec 23 as we won't get the current month Jan 24 values until we reach the end of current month Jan 24.

 

Thanks, in advance.

vpogaku
6 - Meteoroid

Hi Hi2023,

 

I have a similar use case where I always want my date field to calculate till previous month end in my YTD calculations.

 

We want our YTD logic to work till end of previous month but should not include current month.

 

For E.g., Even though we don't have current month data (Jan 24) our YTD should work for one prior month of Dec 23 as we won't get the current month Jan 24 values until we reach the end of current month Jan 24.

 

Can you please share your thoughts here?

Labels
Top Solution Authors