title: CAML query to retrieve only published pages from SharePoint 2007?
body: <p>I am currently retrieving all pages and filtering out ones that are not published in the code, checking whether <code>DateTime.Now</code> is smaller than this:</p>
  
  <pre><code>static readonly DateTime IMMEDIATE_PUBLISH = new DateTime(1900, 1, 1);
  
  public static DateTime PublicationDate(this SPListItem item)
  {
      // get start publish date
      PublishingPage page = item.Publishing();
      if (page != null)
      {
          bool isPublished = (page.ListItem.File != null)
              ? (page.ListItem.File.Level == SPFileLevel.Published)
              : true;
          bool isApproved = (page.ListItem.ModerationInformation != null)
              ? (page.ListItem.ModerationInformation.Status == SPModerationStatusType.Approved)
              : true;
          if (isPublished &amp;&amp; isApproved &amp;&amp; (DateTime.Now &lt; page.EndDate))
          {
              return page.StartDate == IMMEDIATE_PUBLISH ? page.CreatedDate : page.StartDate;
          }
          return DateTime.MaxValue;
      }
      // not a scheduled item. treat as published
      return DateTime.MinValue;
  }
  </code></pre>
  
  <p>What would be the equivalent CAML query, so that I SharePoint doesn't pull unnecessary items from the database?</p>