luisr69
asked on
How do I get latest(max) date from the field?
I need to getLatestDate from certain field with some records.
Using C#, How do I compare all those dates in the records?
Let's say I have this table:
Test1: 5/20/2010
Test2: 8/12/2010
Test3: 2/1/2011
Test4: 11/2/2010
I want the code to return 2/1/2011 from Test3
Thanks,
Danny
Using C#, How do I compare all those dates in the records?
Let's say I have this table:
Test1: 5/20/2010
Test2: 8/12/2010
Test3: 2/1/2011
Test4: 11/2/2010
I want the code to return 2/1/2011 from Test3
Thanks,
Danny
Are you talking about a database field, or a class field? What version of .NET are you using? Do you have any knowledge about LINQ?
Where are the dates stored?
ASKER
Hi,
It's a database field, .NET 3.5
I'm using SQL Statement with Store Procedure.
Thanks, sorry I'm new with ASP.NET, please bear with me.
It's a database field, .NET 3.5
I'm using SQL Statement with Store Procedure.
Thanks, sorry I'm new with ASP.NET, please bear with me.
You can get the correct value from a SQL statement like this:
select max(YourDateColumn) from YourTable
I hope this helps.
select max(YourDateColumn) from YourTable
I hope this helps.
If you have a fixed number of fields, then you might be able to use a CASE statement in the query, but MAX only returns the maximum for a single column, not the max between different fields in the same row.
ASKER
SELECT MAX works as an SQL statement. Thanks,
How do I start with the C# Code?
And yes, it's a single column only for now.
Thank you.
How do I start with the C# Code?
And yes, it's a single column only for now.
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.