Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date comparisons
Message
 
À
17/06/2004 09:42:05
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00914601
Message ID:
00914819
Vues:
13
Bonnie,
Thank you for your suggestion.
I used it and ended up having to add "CDATE()" to it...
Apparently the "&" was turning the return value of TODAY() into it's string equivilent. (the rest of myProposedFilter was a string expression)

Rick

>Rick,
>
>I've never used Access, but in SQL Server you need to worry about the time as well as the date. Since you're not using a time, it's assumed to be 00:00:00. I'm not sure about the Today() method in your code, maybe it's different in VB, but in C# one uses a property DateTime.Today. At any rate, the time is still 00:00:00. So, you really should never do an equal when you're talking about dates. Change it to:
>
>                myProposedFilter = myProposedFilter & " AND " & _
>                " (Activities.Start_Time >= " & Today() & " OR " &_
>                "  Activities.Start_Time <  " & Today().AddDays(1) & ") "
>
>Not 100% sure if that syntax will work, but you get the picture. Play with it.
>
>HTH,
>~~Bonnie
>
>
>>I have a simple question...
>>My question is, "What is the correct way to do this date comparison?"
>>The way I'm doing it now doesn't work.
>>
>>I have my data in an Access table
>>I have a field (Start_Time), declared as a Date/Time
>>I want to return all records where the Start_Time is from today.
>>
>>The select statement I'm using is
>>
>>SELECT Activities.Unique_ID as Activity,
>>		Activities.Contact_ID as Contact,
>>		Contacts.Company as Company,
>>		Activities.Type,
>>		Activities.Start_Time as StartDate,
>>		Activities.Duration,
>>		Activities.Priority,
>>		Activities.Regarding,
>>		Users.User_Name as For_User,
>>		Activities.recurring_freq as Frequency,
>>		Activities.recurring_until as Recurring_Until,
>> 		Activities.Completed as Completed
>>	FROM (Activities
>>		INNER JOIN Users
>>			ON Activities.schedl_for = Users.Unique_ID)
>>		INNER JOIN Contacts
>>			ON Activities.Contact_ID = Contacts.Unique_ID
>>	WHERE  (Activities.Schedl_For = 26)
>>		AND  (Activities.Start_Time = 6/17/2004)
>>	ORDER BY Activities.Start_Time DESC
>>
>>
>>The WHERE clause is actually being build in code...
>>
>>...
>>                myProposedFilter = myProposedFilter & " AND " & _
>>                " (Activities.Start_Time = " & Today() & ") "
>>...
>>Session("myProposedFilter") = myProposedFilter
>>...
>>SelectCommand = "SELECT " & _
>>                      "Activities.Unique_ID as Activity, " & _
>>                      "Activities.Contact_ID as Contact, " & _
>>                      "Contacts.Company as Company, " & _
>>                      "Activities.Type, " & _
>>                      "Activities.Start_Time as StartDate, " & _
>>                      "Activities.Duration, " & _
>>                      "Activities.Priority, " & _
>>                      "Activities.Regarding, " & _
>>                      "Users.User_Name as For_User, " & _
>>                      "Activities.recurring_freq as Frequency, " & _
>>                      "Activities.recurring_until as Recurring_Until, " & _
>>                      "Activities.Completed as Completed " & _
>>                   "FROM (Activities INNER JOIN Users ON Activities.schedl_for = Users.Unique_ID) " & _
>>                          " INNER JOIN Contacts ON Activities.Contact_ID = Contacts.Unique_ID " & _
>>                   "WHERE " & Session("myProposedFilter") & _
>>                   " ORDER BY Activities.Start_Time DESC "
>>
>>
>>TIA,
>>Rick
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform