QUERY: Find the first day of the current month and then add two months | Community
Skip to main content
November 22, 2022
Solved

QUERY: Find the first day of the current month and then add two months

  • November 22, 2022
  • 2 replies
  • 1184 views

Adobe Campaign Classic v7

QUERY: Find the first day of the current month and then add two months

Example:  Today: 11/22/2022   First Day of Month: 11/01/2022  Plus two months: 01/01/2023

 

My process has: checkDate before toDate(ToInteger(day of ToDate(current date) - 1) days before) + 2 month(s) in query window but does not work.

How do you write this query?

 

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by juantonio_18

Hello,

 

To identify first day of the month, you can use the Function YearAndMonth(<Date>). After that you just have to add two months. So you'll have something like this:

 

AddMonths(YearAndMonth(GetDate()), 2)

 

I hope this helps you.

 

Best.

2 replies

juantonio_18
juantonio_18Accepted solution
Level 2
November 22, 2022

Hello,

 

To identify first day of the month, you can use the Function YearAndMonth(<Date>). After that you just have to add two months. So you'll have something like this:

 

AddMonths(YearAndMonth(GetDate()), 2)

 

I hope this helps you.

 

Best.

AkshayAnand
Community Advisor
Community Advisor
November 23, 2022

Hi @tjforce24 

 

You can use the below code in your Query activity in advance selection :-

Day(DateOnly(GetDate())) - (Day(DateOnly(GetDate())) - 1 )+'/'+ Iif((Month(DateOnly(GetDate())) + 2) > 12, (Month(DateOnly(GetDate())) + 2) - 12 , (Month(DateOnly(GetDate())) + 2)) + '/' + Iif((Month(DateOnly(GetDate())) + 2) > 12, Year(DateOnly(GetDate())) +1 , Year(DateOnly(GetDate())))

 

Regards