Share via

pipeline expression - previous month

arkiboys 9,711 Reputation points
2022-09-14T16:17:11.367+00:00

hello,
This is what I am using inside the copy activity pipeline where I pass in the daysBack, i.e. -5 and then it build the string with dates from 5 days ago:

@markus.bohland@hotmail.de (
dataset().dateFieldName, ' > ', formatDateTime(addDays(dataset().currentDate, int(dataset().daysBack)), 'yyyy-MM-dd'),
' and ', dataset().dateFieldName, ' < ', formatDateTime(dataset().currentDate, 'yyyy-MM-dd')
)
This works fine but now this is what I would like to do where the above expression gives back data for the previous month when-ever I run it.
for example, something like this perhaps?
@markus.bohland@hotmail.de (
dataset().dateFieldName, ' > ', firstDayOfPreviousMonth - 1,
' and ', dataset().dateFieldName, ' < ', LastDayOfPreviousMonth + 1
)

Thank you

Azure Data Factory
Azure Data Factory

An Azure service for ingesting, preparing, and transforming data at scale.


Answer accepted by question author

Nasreen Akter 10,896 Reputation points Volunteer Moderator
2022-09-14T20:19:10.62+00:00

Hi @arkiboys ,

you can get Days with the following expressions:

'2022-01-31' (last day of the month before previous month) --> addDays(formatDateTime(subtractFromTime('2022-03-20', 1, 'MONTH'),'yyyy-MM-01'), -1, 'yyyy-MM-dd')
and '2022-02-01' (first day of previous month) --> formatDateTime(subtractFromTime('2022-03-20', 1, 'MONTH'),'yyyy-MM-01')

Thanks!

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.