$olddate = Get-Date -Date "31-dec-2013 00:00:00" -Format d.M.yyyy
$Now = Get-date -Format d.M.yyyy
How can I check if $olddate is earlier than $Now?
Supposing the current date is 2015/5/25, with the following formula, you can determine if date has passed compared with today’s date. Please do as follows. 1. Select a blank cell which is adjacent to the date you want to determine if it is overdue. Enter the below formula into it, and then press the Enter key. 2.
Excel Determine if Dates Have Passed 1 Select the range with dates you want to compare with current date and select the overdue dates,... 2 In the Select Specific Cells dialog box, select Cell in the Selection type section,... 3 Then a Select Specific Cells prompt box pops up to tell you how many cells will be selected,... See More....
Using the IF Function with DATEVALUE Function If you want to use a date in your IF function’s logical test, you can wrap the date in the DATEVALUE function. This function converts a date in text format to a serial number that Excel can recognize as a date. If you put a date within quotes, it is essentially a text or string value.
Calculate Future or Past Dates in Excel Using IF Formula In this example, we will check if a date is in a range or not. For example, take today’s day into account. The motive of this example is to check whether the delivery will take place or not within ten days.
If your store them as DateTime
instead of as formatted strings, you can use the less-than operator (-lt
) just like with regular numbers, and then use the format operator (-f
) when you need to actually display the date:
$olddate = Get-Date -Date "31-dec-2013 00:00:00"
$Now = Get-Date
if($olddate -lt $Now){
"`$olddate is in the past!"
"{0:d.M.yyyy}" -f $olddate
"{0:d.M.yyyy}" -f $Now
}
You can also do a comparison on Ticks. I.e.: $olddate.Ticks
will be -lt
then $Now.Ticks
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With