How to retrieve the correct Account records from SOQL query?Return more than 2000 records (SOQL)Using a specific dynamic date in a SOQL query where clauseQuery Optimization for Bulk data using a Formula field in the WHERE clauseSOQL query with inner query doesn't recognize understand the relationshipSOQL Query to compare dates on child object recordsSOQL query in Visualforce page returning only first 250 records when text area (long) is included in queryNot all records returned in SOQL QueryGet last modified data older than 30 days from now in SOQL

Python: write 2**n - 1 as a recursive function

Would fantasy dwarves be able to invent and/or manufacture the radio?

Is there a general theory of "compactification"?

What's the part number of this LEGO element?

Heat-shrink tubing available as a roll like adhesive tape?

should I include offer letter from a different institution in my application for a faculty position

How do social media apps notify you when someone else takes a screenshot of your profile?

SpaceX Starship landing on Moon or Mars: why doesn't it fall over?

Was Hitler exclaiming "Heil Hitler!" himself when saluting?

Why does Ubuntu resolve the name `_gateway` to the default gateway instead of `gateway`?

What happened to SEV?

Why is Microwaved mac & cheese burnt where they touch?

Duality in mixed integer linear programs

Response to referee after rejection

What kind of mathematical disciplines would be most useful for physics?

Palindrome and Reverse a String Problems (JavaScript, Python)

Is encrypted e-mail sent over TLS 1.3 a form of "forward secrecy" (similar to something like Signal)?

What are the meanings of `B.C. 3/8"` and `6-11/32"`?

Can a standard NEMA 5-15 outlet be installed in a round ceiling box?

Piece de Resistance - Jack in all Tags... But Master in All?

Can I catch arrows if I am not a monk?

High power microwave weapons for future spacecraft in somewhat hard sci-fi setting

Copying files: Does Windows write to disk if files are identical

Is rent considered a debt?



How to retrieve the correct Account records from SOQL query?


Return more than 2000 records (SOQL)Using a specific dynamic date in a SOQL query where clauseQuery Optimization for Bulk data using a Formula field in the WHERE clauseSOQL query with inner query doesn't recognize understand the relationshipSOQL Query to compare dates on child object recordsSOQL query in Visualforce page returning only first 250 records when text area (long) is included in queryNot all records returned in SOQL QueryGet last modified data older than 30 days from now in SOQL






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









2

















In account record I have a custom myDate__c field of type date.



I need to retrieve all Account records where myDate__c is older than 45 days.



I've tried with the following query:



SELECT id, name 
FROM Account
WHERE myDate__c <= today() - 45


However I received a warning message:




Date and number are incompatible types




How to change my query to retrieve the correct Account records?



I need only SOQL. No Apex.










share|improve this question


































    2

















    In account record I have a custom myDate__c field of type date.



    I need to retrieve all Account records where myDate__c is older than 45 days.



    I've tried with the following query:



    SELECT id, name 
    FROM Account
    WHERE myDate__c <= today() - 45


    However I received a warning message:




    Date and number are incompatible types




    How to change my query to retrieve the correct Account records?



    I need only SOQL. No Apex.










    share|improve this question






























      2












      2








      2








      In account record I have a custom myDate__c field of type date.



      I need to retrieve all Account records where myDate__c is older than 45 days.



      I've tried with the following query:



      SELECT id, name 
      FROM Account
      WHERE myDate__c <= today() - 45


      However I received a warning message:




      Date and number are incompatible types




      How to change my query to retrieve the correct Account records?



      I need only SOQL. No Apex.










      share|improve this question

















      In account record I have a custom myDate__c field of type date.



      I need to retrieve all Account records where myDate__c is older than 45 days.



      I've tried with the following query:



      SELECT id, name 
      FROM Account
      WHERE myDate__c <= today() - 45


      However I received a warning message:




      Date and number are incompatible types




      How to change my query to retrieve the correct Account records?



      I need only SOQL. No Apex.







      soql query date






      share|improve this question
















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 29 at 0:20









      Jackson Chen

      2,3722 gold badges6 silver badges28 bronze badges




      2,3722 gold badges6 silver badges28 bronze badges










      asked May 28 at 21:15









      sfdcadmdevsfdcadmdev

      424 bronze badges




      424 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          7


















          I recommend you read up on Date Formats and Date Literals in the SOQL and SOSL Reference. This resource covers several ways you can format date fields that you may find useful in the future. Specifically for your current use case:




          Date Literal

          LAST_N_DAYS:n



          Range

          For the number n provided, starts 00:00:00 of the current day and continues for the past n days.



          Example

          SELECT Id FROM Account WHERE CreatedDate = LAST_N_DAYS:365







          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "459"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f263999%2fhow-to-retrieve-the-correct-account-records-from-soql-query%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown


























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            7


















            I recommend you read up on Date Formats and Date Literals in the SOQL and SOSL Reference. This resource covers several ways you can format date fields that you may find useful in the future. Specifically for your current use case:




            Date Literal

            LAST_N_DAYS:n



            Range

            For the number n provided, starts 00:00:00 of the current day and continues for the past n days.



            Example

            SELECT Id FROM Account WHERE CreatedDate = LAST_N_DAYS:365







            share|improve this answer






























              7


















              I recommend you read up on Date Formats and Date Literals in the SOQL and SOSL Reference. This resource covers several ways you can format date fields that you may find useful in the future. Specifically for your current use case:




              Date Literal

              LAST_N_DAYS:n



              Range

              For the number n provided, starts 00:00:00 of the current day and continues for the past n days.



              Example

              SELECT Id FROM Account WHERE CreatedDate = LAST_N_DAYS:365







              share|improve this answer




























                7














                7










                7









                I recommend you read up on Date Formats and Date Literals in the SOQL and SOSL Reference. This resource covers several ways you can format date fields that you may find useful in the future. Specifically for your current use case:




                Date Literal

                LAST_N_DAYS:n



                Range

                For the number n provided, starts 00:00:00 of the current day and continues for the past n days.



                Example

                SELECT Id FROM Account WHERE CreatedDate = LAST_N_DAYS:365







                share|improve this answer














                I recommend you read up on Date Formats and Date Literals in the SOQL and SOSL Reference. This resource covers several ways you can format date fields that you may find useful in the future. Specifically for your current use case:




                Date Literal

                LAST_N_DAYS:n



                Range

                For the number n provided, starts 00:00:00 of the current day and continues for the past n days.



                Example

                SELECT Id FROM Account WHERE CreatedDate = LAST_N_DAYS:365








                share|improve this answer













                share|improve this answer




                share|improve this answer










                answered May 28 at 21:21









                Adrian LarsonAdrian Larson

                117k19 gold badges141 silver badges282 bronze badges




                117k19 gold badges141 silver badges282 bronze badges































                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Salesforce Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f263999%2fhow-to-retrieve-the-correct-account-records-from-soql-query%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown









                    Popular posts from this blog

                    Tamil (spriik) Luke uk diar | Nawigatjuun

                    Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                    Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?