Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

How Do You Search for most Current Date from a Date Field Column Using Link?

Using link with C# How do you search a table on the date column for the most current date from MS SQL Server?

Thanks,

Dan
0
danielolorenz
Asked:
danielolorenz
  • 2
1 Solution
 
DataCruncherCommented:
I do not know C#, but from a SQL query point of view:

To retrieve the value of the most recent date in a given column:
SELECT MAX(MY_DATE_COLUMN) FROM MY_TABLE;

Open in new window


To retrieve the table record for that date:
SELECT * FROM MY_TABLE WHERE MY_DATE_COLUMN = (SELECT MAX(MY_DATE_COLUMN) FROM MY_TABLE);

Open in new window

0
 
jmcmunnCommented:
Are you just looking for a value of the column?

This works in Linqpad, once you have the connection set up etc...
SomeTable.Max(s=>s.Somedatecolumn)

Not knowing your surrounding code, it is hard to say exactly what you are looking for.  Can you provide a little more info on where in the process you are?  (do you have the datatable already full...are you trying to open the connections etc?)
0
 
danielolorenzAuthor Commented:
Yes, the database is already full.

I already wrote and tested the link command:
pofEndDate = String.Format("{0:yyyy-MMM-dd}", participations.Where(p => p.ParticipationStatus == AugeoOperationContext.Current.Plugin.Statuses.ParticipationStatus.Terminated || p.ParticipationStatus == AugeoOperationContext.Current.Plugin.Statuses.ParticipationStatus.Inactive).OrderByDescending(p => p.Arrangement.EndDate).FirstOrDefault().Arrangement.EndDate);
0
 
danielolorenzAuthor Commented:
Thanks and that was great help
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now