.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh

Home >> Forum >> VB.Net >> Post New QuestionBookmark and Share Subscribe to Forum

calculation pblm

Posted By: vidhya     Posted Date: October 15, 2010    Points:2   Category :VB.Net
worked in student attendance project in vb.net,i put presnt the value is saved 1 in database1,i put absent the value is saved 0 in database,how to calculate the total nbr of present days beteen two dates,date is set in datetime value in db

If con.State = ConnectionState.Closed Then
End If

Dim start As New DateTime
Dim endd As New DateTime
'when you pick vlaue from datetimpicker then use DateTimePicker.value
start = DateTimePicker1.Value
endd = DateTimePicker2.Value

cmd = New SqlCommand("select count(Come)from attendance where Date between '" & start & "' and '" & endd & "' and Stuname='" & TextBox2.Text & "'", con)
Dim i As Integer
i = cmd.ExecuteScalar
If i > 0 Then
TextBox1.Text = i.ToString()
End If

this coding is working actually 3 present are in the database bt shown the output is2

Author: Santosh             
Posted Date: October 15, 2010     Points: 5   

Hi Vidhya,

just convert the datetimepiker value to string as 'dd/MM/yyyy' format
and after that just change the query like

cmd = New SqlCommand("select count(Come)from attendance where convert(varchar(10),Date,103) between '" & start & "' and '" & endd & "' and Stuname='" & TextBox2.Text & "'" and saved = 1 , con)

in ur query u missed ( saved = 1) condition becaz saved = 1 means present...

hope this will help u.

if not please tell me the problem.....


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend