Loading
Salesforce now sends email only from verified domains. Read More
Journeys and Automations in Marketing Cloud Engagement
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Query: Subscribers by Date or Time Frame

          Query: Subscribers by Date or Time Frame

          Find subscribers who were added within a specific date or range of dates.

          Before You Begin

          To use this example, you need a working knowledge of SQL. You can copy and paste the code samples, but you must configure them for your setup.

          Create a Target Data Extension

          In Contact Builder or Email Studio, create a standard data extension with these properties and fields. This data extension is the destination for your query's data output.

          Target Data Extension SubscribersByListByDate
          External Key SubscribersByListByDate
          Note
          Note If you create the data extension in Email Studio, the Nullable column replaces the Required column. If a field isn’t required, select Nullable. If a field is required, don’t select Nullable.
          Primary Key Name Data Type Required Length Default Value
          X SubscriberKey Text X 254  
            EmailAddress EmailAddress X 254  
            ListID Number X    
            ListName Text X 100  
            DateAdded Date X    

          Create a Query Activity

          In Automation Studio, create an SQL query with these properties.

          Query Name SubscribersByListByDate
          External Key SubscribersByListByDate

          Sample Query

          Copy and paste this query.

          SELECT l.subscriberkey,
                 l.emailaddress,
                 l.listid,
                 l.listname,
                 l.createddate AS DateAdded
          FROM   [_listsubscribers] AS l
          WHERE  l.listid = MY_LIST_ID
                 AND createddate BETWEEN 2021-11-01 AND 2021-12-01

          Finalize the Query Activity

          Customize the query. Use the line numbers in Automation Studio to identify which lines to modify.

          • On line 7, replace MY_LIST_ID with the ID of your subscriber list. If you don’t know your list ID, go to Email Studio, select Subscribers | Lists | My List, and view its properties.
            Screenshot of Email Studio showing an list's details and highlighting the List ID.
          • On the last line, replace the date range with your time frame in YYYY-MM-DD format.

          Link the query to the target data extension.

          Target Data Extension SubscribersByListByDate
          Data Action Overwrite

          Save your query activity, and then create and activate an automation that uses the activity.

          Query Variation: Find Subscribers by Date

          To find subscribers who were added on a specific date, use this code and update the last line with your date.

          SELECT l.subscriberkey,
                 l.emailaddress,
                 l.listid,
                 l.listname,
                 l.createddate AS DateAdded
          FROM   [_listsubscribers] AS l
          WHERE  l.listid = MY_LIST_ID
                 AND l.createddate BETWEEN 2021-11-01 00:00:00 AND 2021-11-01 23:59:59
           
          Loading
          Salesforce Help | Article