Nur Muhammad
Nur Muhammad

Reputation: 111

query by specific day asp.net c#

I have a grid view. Under this, I have used some parameter like @LHNoofOverdueEMI and @LHDisbDate. I want to query by grater than or equal value of @LHNoofOverdueEMI and equal to value of specific day value of any month or year from @LHDisbDate. All are details below:

page.aspx

<asp:SqlDataSource ID="DSGVRecList" runat="server" 
ConnectionString="<%$ ConnectionStrings:OptimaWebCustomerQueryCon %>" 
SelectCommand="select LHID, LHAcNo, LhAcName, LHIntRate, LHDisbDate
LHDrawingPower, LHtotalDisbAmt, LHEMI, LHNoofOverdueEMI,  LHUploadDate
from dbo.TblLoanHistory where
(YEAR(LHUploadDate) = YEAR(GETDATE())) AND (MONTH(LHUploadDate) = MONTH(GETDATE())) 
AND LHNoofOverdueEMI ??? 
AND  LHDisbDate ??? "

onselecting="DSGVRecList_Selecting">
<SelectParameters>
<asp:ControlParameter ControlID="txtNoofOverDue" Name="LHNoofOverdueEMI" PropertyName="Text" /> 
<asp:ControlParameter ControlID="txtEMIDate" Name="LHDisbDate" PropertyName="Text" />  
</SelectParameters>
</asp:SqlDataSource>

c#

protected void DSGVRecList_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
if (txtEMIDate.Text.Length == 0) e.Command.Parameters["@LHDisbDate"].Value = "%";
else e.Command.Parameters["@LHDisbDate"].Value = txtEMIDate.Text;
if (txtNoofOverDue.Text.Length == 0) e.Command.Parameters["@LHNoofOverdueEMI"].Value = "%";
else e.Command.Parameters["@LHNoofOverdueEMI"].Value = txtNoofOverDue.Text;
}

Upvotes: 0

Views: 47

Answers (1)

Mido
Mido

Reputation: 120

Have you tried using: SELECT DATEPART(weekday,GetDate()) ?

It returns the day of the week based on the specified date. 1 = Sunday and 7 = Saturday.

Upvotes: 1

Related Questions