Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Howto build a Select filter with DateTime
Message
De
22/09/2007 12:30:03
John Baird
Coatesville, Pennsylvanie, États-Unis
 
 
À
22/09/2007 12:04:46
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
01256085
Message ID:
01256087
Vues:
10
>Hi,
>
>I'm trying to construct a DataTable.Select filter expression based on a DateTime comparison. Something like:
>string ds = DateTime.Now.ToString();
>string s = "BackupType=1 AND BackupFinishDate < Convert('" + ds + "','System.DateTime')";
>DataRow[] drs = dt.Select(s, "BackupFinishDate DESC");
>The Select gives a FormatException with "String was not recognized as a valid DateTime".
>The resulting s in the select looks like this:
>"BackupType=1 AND BackupFinishDate < Convert('22/09/2007 17:02:31','System.DateTime')"
>
>How do I get this to work?
>TIA,
>Viv


Hi Viv,

I don't think you need the convert function. Again, off the top of my head, try this:
DataRow[] rows = dt.Select("BackupType=1 AND BackupFinishDate < #" + ds + "#");
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform