Query Month and Day from Customers Date of Birth | Community
Skip to main content
RyanMoravick
Level 4
September 23, 2024
Solved

Query Month and Day from Customers Date of Birth

  • September 23, 2024
  • 1 reply
  • 1076 views

I was wondering if it was possible to query customers whose birthday is today using their date of birth field (date field). 

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 Parvesh_Parmar

Hello @ryanmoravick ,

 

Assuming you're referring to running this query in Query Service, there are two out-of-the-box fields under the person field group for birth date: birthDayAndMonth and birthDate.

 
 

 

 

 

Since you're asking about the date field, I believe you are referring to birthDate.

If your birth date data is stored in the birthDate field, you can use the following query to get customers whose birthday is today:

 

SQL:
 
SELECT * FROM table_name WHERE TO_CHAR(person.birthDate, 'MM-DD') = TO_CHAR(CURRENT_DATE, 'MM-DD');

 

This query formats both the birthDate and CURRENT_DATE as MM-DD (month and day) and compares them to return the customers whose birthday is today.

 

Kr,

Parvesh

1 reply

Parvesh_Parmar
Community Advisor
Parvesh_ParmarCommunity AdvisorAccepted solution
Community Advisor
September 24, 2024

Hello @ryanmoravick ,

 

Assuming you're referring to running this query in Query Service, there are two out-of-the-box fields under the person field group for birth date: birthDayAndMonth and birthDate.

 
 

 

 

 

Since you're asking about the date field, I believe you are referring to birthDate.

If your birth date data is stored in the birthDate field, you can use the following query to get customers whose birthday is today:

 

SQL:
 
SELECT * FROM table_name WHERE TO_CHAR(person.birthDate, 'MM-DD') = TO_CHAR(CURRENT_DATE, 'MM-DD');

 

This query formats both the birthDate and CURRENT_DATE as MM-DD (month and day) and compares them to return the customers whose birthday is today.

 

Kr,

Parvesh

Parvesh Parmar – Adobe Community Advisor https://www.linkedin.com/in/parvesh-parmar/
RyanMoravick
Level 4
November 14, 2024

@parvesh_parmar Im attempting to replicate this for customer loyalty anniversary date, which is a date time field. When running the query, it doesn't return anyone.

SELECT *
FROM table_name
WHERE TO_CHAR(AppSignupDatetime, 'MM-DD') = TO_CHAR(CURRENT_DATE, 'MM-DD');

 

Since the field is a date time field, will that change the date syntax in the query from 'MM-DD' to 'YYYY-MM-DDThh:mm:ss.SSSZ'?