Removing data from returned information.

I am making an SQL Query that brings back a list of files and their paths. They have different file paths and different file names ofc.

The file names are dates and time in the following format:


What I need to do is take the filepath that has the latest date and time, strip off everything except the date and time part and then using the date and time re-query the database.

I have very few ideas on how to do this.

EDIT: The date will be changing and I need to take the latest when ever the program is run.


My first idea would be to treat everything the query returns as strings

When you get your result set, you could iterate through it storing the record you want in a string or multiple strings. You can compare strings with firststring.Compare(secondstring) it returns 1 or greater if the secondstring is alfabeticaly after firststring.

Then use substring to extract the part of the string you want

string inf = latestdate.Substring(startindex, length);

Hope this helps

use the standard .NET file operation libraries

something like:

using System.IO;
string myFileNameWithFullPath;
DateTime newDate = DateTime.Parse(Path.GetFileName(myFileNameWithFullPath));

string tmps = Path.GetFileNameWithoutExtension(filenameFromSQL);
DateTime myDateTime = DateTime.Parse(String.Format("{1}/{2}/{0}",
         tmps.Substring(0,4), tmps.Substring(5,2), tmps.Substring(7,2));

Need Your Help

Learning how to do quicksort

algorithm sorting

I am in university trying to learn how to use quick sort. I am going to make a program in a couple weeks on it, but first I am trying to understand how it works. I found a homework problem that looks

C# xmlwriter sql server

c# xml nodes

From SQL Server 2008, used for xml auto, root('ROOT'), type, elements xsinil to get this output: