Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Am I tired ?
Message
De
09/02/2008 12:45:46
 
 
À
09/02/2008 11:04:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
01291041
Message ID:
01291073
Vues:
14
You *must* be tired! <g>

Using Cetin's example, all you need to do is change the .ToString() parameter, since he showed the day/month/year format in his example. Combine it with your code, and come up with this:
cmd.CommandText =
String.Format("Select * From EventInfo Where EventDate >= #{0}# And EventDate <= #{1}#",
              startDateString, endDateString);
....

DateTime startDate = new DateTime(cal1.VisibleDate.Year, cal1.VisibleDate.Month, 1).AddDays(-7);
DateTime endDate   = new DateTime(cal1.VisibleDate.Date.AddMonths(1).Year, cal1.VisibleDate.Date.AddMonths(1).Month, 1).AddDays(7);

string startDateString = startDate.ToString("MM-dd-yyyy");
string endDateString   = endDate.ToString("MM-dd-yyyy");
~~Bonnie


>Hi Cetin,
>
>In fact I am fighting whole day with DataCalendar example by Mike Ellison and here is
>problem:
>
>
>
>cmd.CommandText =
>String.Format("Select * From EventInfo Where EventDate >= #{0}# And EventDate <= #{1}#",
>              startDate, endDate);
>....
>
>DateTime startDate = new DateTime(cal1.VisibleDate.Year, cal1.VisibleDate.Month, 1).AddDays(-7);
>DateTime endDate = new DateTime(cal1.VisibleDate.Date.AddMonths(1).Year, cal1.VisibleDate.Date.AddMonths(1).Month, 1).AddDays(7);
>
>
>
>this gives error because date must be in form MM/dd/yyyy
>
>if I put hardcoded dates like
>
>cmd.CommandText =
>"Select * From EventInfo Where EventDate >= #03/03/2007# And EventDate <= #11/24/2007#";
>
>that is working !
>
>How should i put in above string startDate and endDate in MM/dd/yyyy format
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform