Query on or after 16th of every month | Community
Skip to main content
Level 4
Dec 26, 2022 8:21 AM UTC
Solved

Query on or after 16th of every month

Hi Team,

 

We have a recurring campaign that runs once in a month and needs to check if a customer has an entry on or after 16th of previous month. can someone help on how to query the same, thanks in advance.

 

Thanks,

Shine v.v

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Shubham_Goyal__
Shubham_Goyal__Accepted solution
Level 6
Dec 26, 2022 9:14 AM UTC

Hi @shinev_ ,

 

Instead of going with Js calculation try this simple function in your query activity and see if this helps:

ToDateTime('"' + toString(Year(MonthsAgo(1))) + '-' + toString(Month(MonthsAgo(1))) + '-16T00:00:00.000Z')

 

Here you use the ToDateTime function which calculates the date from the input string and in the input string you can calculate the Year of last month and the month of last month and hard code rest like 16 in your case.

See if this gives you desired results.

 

 

Br,

Shubham

4 replies

juantonio_18
Level 2
Dec 27, 2022 5:14 PM UTC

You can do what you need using the following functions:

 

Created Date     on or after   AddDays(YearAndMonth(SubMonths(GetDate(), 1)), 15)

Translate
ShineV_Author
Level 4
Dec 27, 2022 5:47 PM UTC

@juantonio_18 , @shubham_goyal__ , both of your solutions are working, thank you so much 🙂 not sure which one to mark as correct reply!! 

 

Translate
Sukrity_Wadhwa
Employee
Jan 5, 2023 6:28 AM UTC

Hi @shinev_, 


Wishing you a very happy new year! 🙂


In such a case, you could mark that one which you ended up using in your practice. Hope this helps resolve the confusion.

 

Thanks! 

Translate
Sukrity Wadhwa
Shubham_Goyal__
Shubham_Goyal__Accepted solution
Level 6
Dec 26, 2022 9:14 AM UTC

Hi @shinev_ ,

 

Instead of going with Js calculation try this simple function in your query activity and see if this helps:

ToDateTime('"' + toString(Year(MonthsAgo(1))) + '-' + toString(Month(MonthsAgo(1))) + '-16T00:00:00.000Z')

 

Here you use the ToDateTime function which calculates the date from the input string and in the input string you can calculate the Year of last month and the month of last month and hard code rest like 16 in your case.

See if this gives you desired results.

 

 

Br,

Shubham

Translate