Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 HOW TO GET THE LAST LATEST DATE

Author  Topic 

rajukotla
Starting Member

9 Posts

Posted - 2008-05-16 : 00:32:30
HOW TO GET THE LAST LATEST DATE..
FOR EG.,
I HAVE DATES LIKE THIS..
3/5/2008
1/5/2008
4/5/2008
8/5/2008
6/5/2008
I NEED TO GET THE RESULT 8/5/2008 AS TODAY IS 16/5/2008

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-05-16 : 04:58:14
hi
try this


declare @t table (date datetime)
insert @t
select convert(datetime, '3/5/2008',103) union all
select convert(datetime, '1/5/2008',103) union all
select convert(datetime, '8/5/2008',103) union all
select convert(datetime, '6/5/2008',103)union all
select convert(datetime, '1/6/2008',103) union all
select convert(datetime, '23/4/2008',103)

select top 1* from @t order by date desc

ok tanx......
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-05-16 : 13:01:54
Maybe:
SELECT MAX(Date) FROM MyTable
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-16 : 14:02:40
SELECT MAX(Date) FROM MyTable WHERE Date < GETDATE()
Go to Top of Page
   

- Advertisement -