why is this causing a problem?

codesmith

Active Member
Joined
Apr 23, 2008
Messages
257
Code:
Sub testDateCompare()
    Dim nmiDate As String
    nmiDate = CDate("23/4/08")
    Dim origDate As String
    origDate = CDate("23/04/2008 15:05")
    origDate = Left(origDate, InStr(origDate, " "))
    
    Dim minDate As String
    minDate = WorksheetFunction.Min(origDate, nmiDate)
    MsgBox minDate
End Sub


Giving '400' error!?

thanks in advance.
 
Last edited:
Read the op's code again.
He wants to compare the dates without time part. (doesn't mean much to me anyway though)

The result is the same.
If the two date/times are on different days, the earliest of the dates (no time component) is the same as the date of the earliest time.

If they are on the same day, that's the date that is returned.

The date of the earliest time = the earliest of the dates without time component.
Int(Min(a,b)) = Min(Int(a),Int(b))
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
The result is the same.
If the two date/times are on different days, the earliest of the dates (no time component) is the same as the date of the earliest time.

If they are on the same day, that's the date that is returned.

The date of the earliest time = the earliest of the dates without time component.
Int(Min(a,b)) = Min(Int(a),Int(b))
Talking about different thing.
I only took OP's sample data, so my posts.
 
Upvote 0

Forum statistics

Threads
1,216,106
Messages
6,128,863
Members
449,473
Latest member
soumyahalder4

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top