# Retrieving user accounts created today, but without the time

**URL:** <https://forums.powershell.org/t/retrieving-user-accounts-created-today-but-without-the-time/18253>\
**Category:** PowerShell Help\
**Created:** [December 29, 2021, 10:48pm UTC](https://forums.powershell.org/t/retrieving-user-accounts-created-today-but-without-the-time/18253 "2021-12-29T22:48:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandwitchloord](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@sandwitchloord](https://forums.powershell.org/u/sandwitchloord)\
**Post date:** [December 29, 2021, 10:48pm UTC](https://forums.powershell.org/t/retrieving-user-accounts-created-today-but-without-the-time/18253/1 "2021-12-29T22:48:58Z")

</div>

Hello and thank you to all who take the time to look at my post and offer assistance!

Currently I am trying to make a script that returns enabled users who were created today or whenever the present day is when it is run, but without the time factored into the date. Right now if I try to run the below it doesn’t return anything. I’ve tried many of the comparison operators but it still doesn’t work.

```
Get-ADUser -Filter "enabled -eq 'true'" -Properties name, whencreated | 
    where {$_.whencreated -like (get-date)}

```

Now if I instead try to find users created in the last two days as an example I can do that, but it is always taking the time into account which is what I want to ignore. I simply want it to find users created on 12/29/21 and not worry about a timestamp at all, just find anyone created on that day at ANY time.

I’ve done a lot of googling and trial and error but am having no such luck. Hopefully my post makes sense and thank you again to any who offer help!

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [December 29, 2021, 11:21pm UTC](https://forums.powershell.org/t/retrieving-user-accounts-created-today-but-without-the-time/18253/2 "2021-12-29T23:21:45Z")

</div>

To get only the “_Date_” part from the current day you can use

```auto
(Get-Date).Date

```

To make the reference and the AD property comparable you have to do this for both. So it looks something like this:

```auto
Get-ADUser -Filter "Enabled -eq '$true'" -Properties WhenCreated | 
    Where-Object {(Get-Date $($_.whencreated)).Date -eq (Get-Date).Date}

```

BTW: The comparison operator _-like_ is not a good choice when it comes to date and time comparisons. Instead you should use `-eq` or `-lt` or `-gt` or `-le` or `-ge`.

So your query could also be written like this:

```auto
Get-ADUser -Filter "Enabled -eq '$true'" -Properties WhenCreated | 
    Where-Object {$_.whencreated -ge (Get-Date).Date}

```

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [December 30, 2021, 12:24am UTC](https://forums.powershell.org/t/retrieving-user-accounts-created-today-but-without-the-time/18253/3 "2021-12-30T00:24:50Z")

</div>

Olaf, FWIW, your solution work perfectly for me.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:19pm UTC](https://forums.powershell.org/t/retrieving-user-accounts-created-today-but-without-the-time/18253/4 "2024-05-16T20:19:52Z")

</div>


