Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3965186
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:25:43+00:00 2026-05-20T03:25:43+00:00

I have tried below but not getting any result back Not sure if i’m

  • 0

I have tried below but not getting any result back
Not sure if i’m doing this well.
Can i filter in the foreach or in my if statement
Thanks in advance

[DateTime] $CreatedDate = $item["Created"] 
$convertedCreatedDate = $CreatedDate.ToString("yyyy-MM-dd")
$today = (Get-Date).AddDays(-1).ToString("yyyy-MM-dd")

foreach ($item in $list.items | where {$convertedCreatedDate -eq $today}) {

    if ($list.items | where {$convertedCreatedDate -eq $today}) 
    {
        Write-Host $item["Created"] 
    }

    Write-Host $item["Created"] 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:25:44+00:00Added an answer on May 20, 2026 at 3:25 am

    You can use a complex expression in your foreach as you’re doing above. I would wrap it in a @() to make the code a bit more readable and to ensure the result is an array (either length 0, 1 or n) e.g.:

    foreach ($item in @($list.items | where {$convertedCreatedDate -eq $today})) {
    

    You can also simplify you’re date testing by using the Date property on a DateTime e.g.:

    $convertedCreatedDate = ([DateTime]$item["Created"]).Date
    $today = (Get-Date).Date
    

    You can also put a complex expression within an if statement condition but PowerShell will only evaluate whether the statement is $true or $false. PowerShell does lots of coercion to try to take something like:

    $list.items | where {$convertedCreatedDate -eq $today}
    

    And convert that to a boolean. Essentially if the pipeline evaluates to a non-empty result, the result is $true otherwise it is $false. This is probably not what you intended.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried rectifying the code below. But I am not able to find
OK have just started getting this error and I'm not sure why. I have
I've tried looking up other help for this problem but I'm just not getting
I want to open an xlsx file, I have tried the below code,but neither
Have tried to find solutions for this and can't really come up with anything.
I want to style mail body. I have tried the below methods to style
I need to echo entire content of included file. I have tried the below:
In .NET I have already tried the configuration below successfully: <system.net> <connectionManagement> <add address=*
I have tried var dateHeaders = HttpContext.Current.Request.Headers[Date] but it contains null, apparently there is
I have tried running the code without the collision, and it works fine. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.