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
 General SQL Server Forums
 New to SQL Server Programming
 Data conversion

Author  Topic 

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2007-12-14 : 01:02:14
Hi guys!

I merely need your help!

I want to convert the following:

Table1

transaction Date
1235 10/18/2006 7:54:02
1235 9/18/2006 7:54:02
1235 8/18/2006 6:54:02

To

Table2 wherein the latest date will be post and the date should have a length of 10 characters. The following table would be the result

transaction Date
1235 10/18/2006






madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-14 : 01:20:14
Select [transaction], max([date]) as [date] from table
group by [transaction]

If you use front end application, do date formation there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2007-12-14 : 03:41:57
Also use CONVERT() on the date, all the information you need is in BOL.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-12-14 : 04:15:31
quote:
Table2 wherein the latest date will be post and the date should have a length of 10 characters

why are you using char/varchar to store data time ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -