function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amogh BabhaleAmogh Babhale 

Trailhead challenge of SOQL for admin

Hi All,

I trying to complete the Modudle SOQL for Admins and stuck on one stage.

In the Fourth Stage "Create Relationship Queries with Custom Objects"

The link of the mudle:-https://trailhead.salesforce.com/content/learn/modules/soql-for-admins/create-relationship-queries-with-custom-objects

I not able to colete the chanllenge where it ask to write a query and assign to list.

So the query is that 


Create a query and assign the query results to the list
Get this information:
The name of the property
The broker’s email address
How long the property has been on market
(Hint: Use API names, not field names or field labels)
Object: Property
Condition: The property was listed within the last 30 days

I am Stuck on "Condition" part where they want listed Property is are within 30 days.

I wrote a query  

SELECT Name, Broker__r.Email__c,Days_On_Market__c FROM Property__c  WHERE

but not able to write a logic for WHERE Clause becase the listed date field is Date type field.

So how can we write the logic for WHERE Clause.

Thanks !! 
 
VinayVinay (Salesforce Developers) 
Hi,

Greetings!

We have separate Trailhead team who can help you with these issues.So,can you please use the below link to reach out to them so that one of the agent will get in touch with you.
Support:https://trailhead.salesforce.com/help

Thank you!

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks,
Vinay Kumar
Amogh BabhaleAmogh Babhale
Hi Vinay,

Thank you for your response .

This is an general query I have about SOQL topic , I am not facing any technical issue witht my  Traihead account.

I will change the catogory of this quetion.

Thanks !!
VinayVinay (Salesforce Developers) 
Can you try below
SELECT Name, Broker__r.Email__c,Days_On_Market__c FROM Property__c  WHERE Days_On_Market__c = LAST_N_DAYS:30

Thanks,
Vinay Kumar
Amogh BabhaleAmogh Babhale
Hi Thanks you for the solution.

Itried that but did not worked 
VinayVinay (Salesforce Developers) 
Do you see any errors?

Try to check below date formats.

https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm

Thanks,
Vinay Kumar
Tejas ShettyTejas Shetty
Hi Amogh,

Please use below query and try:
[SELECT Name,Broker__r.Email__c,Days_On_Market__c from Property__c WHERE Days_On_Market__c  <= 30 ]

Thanks,
Tejas
Karl HempelKarl Hempel
It is working. Thanks
yatri patelyatri patel
Hi all...  
My query ran properly but still show me the error that "your dreamhouse package is not installed" which I did.
 
Douglas Gonçalves CarvalhoDouglas Gonçalves Carvalho
I think that solves your problem.

public class PropertyUtility {
    public static void newListedProperties()
    {
        List<Property__c> newPropList = [SELECT Name, Broker__r.Email__c, Days_On_Market__c 
                                                                          FROM Property__c  
                                                                          WHERE Date_Listed__c =    LAST_N_DAYS:30];
        for (Property__c prop : newPropList){
           
            String propEmail = 'Property Name: ' + prop.Name + ' Property Email: ' + prop.Broker__r.Email__c;
            system.debug(propEmail);
        }
    }
}
Mahesh KoturwarMahesh Koturwar
only add -
WHERE Date_Listed__c =    
LAST_N_DAYS:30
Tikam TalrejaTikam Talreja
I used this code and it's working fine for me

public class PropertyUtility {
    public static void newListedProperties(){
        List<Property__c> newPropList = [select name,broker__r.email__c,days_on_market__c from property__c where days_on_market__c <=30];
        for(Property__c prop : newPropList)
        {
            String propEmail = prop.name + ':' + prop.broker__r.email__c;
            System.debug(propEmail);
        }
    }
}
Gowtham VuppuGowtham Vuppu
public class PropertyUtility {
    public static void newListedProperties(){
        list <Property__c>newPropList = [SELECT Name,Broker__r.Email__c,Days_On_Market__c from property__c where Date_Listed__c = LAST_N_DAYS:30];
        for (Property__c prop:newPropList){
         string propEmail= prop.Name+':'+prop.Broker__r.Email__c;
         system.debug(propEmail);   
        }
    }

}
Rishav GuptaRishav Gupta
public class PropertyUtility {
    
     public static void newListedProperties(){
  List<Property__c> newPropList =[Select Name ,Broker__r.Email__c,Days_On_Market__c From Property__c Where Days_On_Market__c<=30];
        for(Property__c pop : newPropList){
            String propEmail = 'Property Name : ' + pop.Name +', Broker Email: ' + pop.Broker__r.Email__c;
            System.debug(propEmail);
        }
    }

}