title: Powershell Export to csv - dynamic daterange
body: <p>I have a csv with user and datetime</p>
  <pre><code>Users DHMS          
  ----- ----          
  A     22/12/21 05:02:00
  B     22/12/21 05:10:00
  C     22/12/21 06:30:00
  D     23/12/21 12:30:00
  A     23/12/21 12:35:00
  B     23/12/21 12:45:00
  C     26/12/21 10:32:00
  D     28/12/21 11:15:00
  A     29/12/21 14:17:00
  B     29/12/21 14:25:00
  </code></pre>
  <p>Is there a simple way to extract from each row a new csv with the rows beetween -30 minutes   / + 30 minutes</p>
  <p>I try to do this</p>
  <pre><code>$culture = [Globalization.CultureInfo]::InvariantCulture
  $Data = Import-Csv '.\test.csv' 
  
  $Data | ForEach-Object {
  
      $DHMS = [DateTime]::ParseExact($($_.DHMS), 'dd/MM/yy HH:m:s', $culture)
  
      
  $DHMSmoins = $DHMS.AddMinutes(-30)
  $DHMSplus =  $DHMS.AddMinutes(30)
  
  
  $path = &quot;.\&quot; + $($_.Users) +&quot;\time.csv&quot;
  
  
  $Data | where { $DHMS  -ge $DHMSmoins  -and $DHMS -le $DHMSplus }
  $Data | Export-Csv $path
  
  }
  </code></pre>
  <p>but problems :</p>
  <p>1/ daterange export is bad</p>
  <p>2/ there is several users so only the last user's row is exported. Is there a way to concatenate the differents csv in one</p>
  <p>Hope to be more clear for Tomalak</p>
  <p>In A folder
  a csv with</p>
  <pre><code>A     22/12/21 05:02:00
  B     22/12/21 05:10:00
  D     23/12/21 12:30:00
  A     23/12/21 12:35:00
  B     23/12/21 12:45:00
  A     29/12/21 14:17:00
  B     29/12/21 14:25:00
  </code></pre>
  <p>in B folder
  a csv with</p>
  <pre><code>A     22/12/21 05:02:00
  B     22/12/21 05:10:00
  D     23/12/21 12:30:00
  A     23/12/21 12:35:00
  B     23/12/21 12:45:00
  A     29/12/21 14:17:00
  B     29/12/21 14:25:00
  </code></pre>
  <p>In C folder
  a csv with</p>
  <pre><code>C     22/12/21 06:30:00
  C     26/12/21 10:32:00
  </code></pre>
  <p>In D folder
  a csv with</p>
  <pre><code>D     23/12/21 12:30:00
  A     23/12/21 12:35:00
  B     23/12/21 12:45:00
  D     28/12/21 11:15:00
  </code></pre>