Solved

Where parameter using just the date part not full datetime

Posted on 2011-03-17
3
625 Views
Last Modified: 2013-11-11
Hi EE,

I have a gridview that is bound to a linqdatasource.  I need to retrieve records based on the date only of a datetime field.  
I've have a hidden field that stores the date I need to filter by.
How do I create a where parameter that only grabs the date?

Thanks,

<asp:LinqDataSource ID="lnqSchedules" runat="server"                ContextTypeName="Service2020.SalonDataClassesDataContext" EnableDelete="True" EnableInsert="True" EnableUpdate="True"  OrderBy="SchedStartDateTime, CustomerID" TableName="Schedules" 
Where="UserID == @UserID &amp;&amp; SchedStartDateTime == @SchedStartDateTime">
<WhereParameters>
<asp:SessionParameter DbType="Guid" Name="UserID" SessionField="UserID" />
<asp:ControlParameter ControlID="hiCalendar" Name="SchedStartDateTime"  PropertyName="Value" Type="DateTime" />
</WhereParameters>
 </asp:LinqDataSource>

Open in new window

0
Comment
Question by:Sheritlw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 35156876
Try:
Where="UserID == @UserID &amp;&amp; SchedStartDateTime.Date == @SchedStartDateTime">

Open in new window

0
 

Author Comment

by:Sheritlw
ID: 35157391
Thanks, that was nice and easy.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35157432
NP. Glad to help  = )
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question