title: Google Analytics shows data only till previous day using c#
body: <p>I have a code to fetch Google Analytics data for a website in c# in Visual studio, it shows or fetch data till previous day, what about today's data?</p>
  
  <p>Below is the code used.</p>
  
  <pre><code>     var today = DateTime.Now;
          var todayDate = today.ToString("yyyy-MM-dd");
          string date = "2012-01-01";
          DateTime dt = Convert.ToDateTime(date);
          var startDate = dt.ToString("yyyy-MM-dd");
          var websiteProfileID = "ga:XXXXXXXX";
          string serviceAccountEmail = "avgvghsbhbh@developer.gserviceaccount.com";
          var certificate = new X509Certificate2(@"D:/RCGA-fdrdrd250d7c.p12", "notasecret", X509KeyStorageFlags.Exportable);
  
          var credential = new ServiceAccountCredential(
          new ServiceAccountCredential.Initializer(serviceAccountEmail)
          {
              Scopes = new[] { AnalyticsService.Scope.Analytics }
          }.FromCertificate(certificate));
  
          // Create the service.
          var service = new AnalyticsService(new BaseClientService.Initializer()
          {
              HttpClientInitializer = credential,
              ApplicationName = "GoogleAnalytics",
          });
  
          var viewTraffic = service.Data.Ga.Get(websiteProfileID, startDate, todayDate, "ga:hits");
          viewTraffic.Dimensions = "ga:userType,ga:date";
          viewTraffic.MaxResults = 10000;
          viewTrafficData = viewTraffic.Execute();
  
          foreach (List&lt;string&gt; row in viewTrafficData.Rows)
          {
              foreach (string col in row)
              {
                  TextWriter tsw = new StreamWriter(@"D:\Hello.txt", true);
                  tsw.WriteLine(col);
                  tsw.Close();
              }
  
          }
  </code></pre>