Skip to main content
RyanMoravick
Level 4
Sep 5, 2024 8:35 PM UTC
Solved

Correct Syntax in AEP Query Service

Hey there, 

 

Im trying to run a query in Query Service and trying to understand the correct syntax for looking at certain dates. I want to look at WHERE transactionDate = '2024-09-04'. However, it returns no results. When I run WHERE transactionDate BETWEEN '2024-09-04' AND '2024-09-05', I can see results for 2024-09-04. So my question is when looking at a single date, what is the correct syntax to use?

 

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
ccg1706
ccg1706Accepted solution
Community Advisor and User Group Leader
Sep 5, 2024 9:34 PM UTC

Hi @ryanmoravick ,

 

The issue might arise if the transactionDate may  include date and time. 

 

To manage this you can try with the following options:

 

-Using DATE(): WHERE DATE(transactionDate)='2024-09-04'

-Using a range of time to cover the entire day: WHERE transactionDate >= '2024-09-04' AND transactionDate <  '2024-09-05'

 

If using the Date function doesn't give you the expected result you can try with CAST or TRUNC.

-CAST: WHERE CAST(transactionDate AS DATE) = '2024-09-04'

-TRUNC: WHERE TRUNC(transactionDate) = '2024-09-04'

 

¡Hope this helps!

 

Regards, 

Celia

11 replies

ccg1706
Community Advisor and User Group Leader
ccg1706Community Advisor and User Group LeaderAccepted solution
Community Advisor and User Group Leader
Sep 5, 2024 9:34 PM UTC

Hi @ryanmoravick ,

 

The issue might arise if the transactionDate may  include date and time. 

 

To manage this you can try with the following options:

 

-Using DATE(): WHERE DATE(transactionDate)='2024-09-04'

-Using a range of time to cover the entire day: WHERE transactionDate >= '2024-09-04' AND transactionDate <  '2024-09-05'

 

If using the Date function doesn't give you the expected result you can try with CAST or TRUNC.

-CAST: WHERE CAST(transactionDate AS DATE) = '2024-09-04'

-TRUNC: WHERE TRUNC(transactionDate) = '2024-09-04'

 

¡Hope this helps!

 

Regards, 

Celia

Translate
RyanMoravick
Level 4
Sep 5, 2024 10:06 PM UTC

Hi @ccg1706 I used your first solution and it worked. Thank you!

Translate
ccg1706
Community Advisor and User Group Leader
Community Advisor and User Group Leader
Sep 6, 2024 2:22 PM UTC

Hi @ryanmoravick,

 

Great, as always happy to help.

 

Regards, 

Celia

Translate