Link to home
Start Free TrialLog in
Avatar of garyz31
garyz31

asked on

Aggregate function for DateTime variables??

I have a table that contains a DateTime column, and another column that I want to use as the group indicator.  I haven't found a function that will select the latest or earliest of the DateTime values for each group.  Does one exist?

Thanks
Avatar of spcmnspff
spcmnspff
Flag of United States of America image

I'm not sure, but will this do what you described?

Latest Date for each group:

Select Group, Max(Date)
From Table
Group By Group


Earliest Date for each group:

Select Group, Min(Date)
From Table
Group By Group
Avatar of SYASSIN
SYASSIN

you can also combine the two above...

select Group, max(date), min(date)
from Table
group by group
ASKER CERTIFIED SOLUTION
Avatar of Mogalappa Adaki
Mogalappa Adaki

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of garyz31

ASKER

Thanks:  I got distracted from this project for quite a while.