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
sd2008sd2008 

Question: Initial term of field expression must be a concrete SObject:Datetime

I got the message for the following code:

 

 

public class FirstClass

{

    public Integer tm()

    {

      Datetime mytime = datetime.now();

      Integer h = mytime.hour;

        return h;

    }

}

 

 

 

I also tried the following, but still not right.

 

 

public class FirstClass

{

    public string tm()

    {

      Datetime mytime = datetime.now();

      string h = string.valueof(mytime.hour);

        return h;

    }

}

Best Answer chosen by Admin (Salesforce Developers) 
JimRaeJimRae

hour is a method call and needs to have the () after it.

 

 

public class FirstClass { public Integer tm() { Datetime mytime = datetime.now(); Integer h = mytime.hour(); return h; } }

 

 

All Answers

JimRaeJimRae

hour is a method call and needs to have the () after it.

 

 

public class FirstClass { public Integer tm() { Datetime mytime = datetime.now(); Integer h = mytime.hour(); return h; } }

 

 

This was selected as the best answer
sd2008sd2008
thank you