
May 12th, 2008, 07:37 AM
|
|
Contributing User
|
|
Join Date: Oct 2006
Posts: 155
  
Time spent in forums: 2 Days 17 h 25 m 26 sec
Reputation Power: 4
|
|
|
ASP.Net/VB.Net - Getting data in grid for last 7 days.
Hi ,
I am using a function to get data in a grid from sql server
now problem is i want to have data of last 7 days from date field , i tried using the date diff but could not worked any method from which i can get the data for last week , last month , last 6 months, last year any function available :
Code:
Displaydata("Select * from users where uDate between '" & Format(Date.Now, "Short Date").ToString & "' and '" & Format(Date.Now, "Short Date").ToString & "' order by uDate")
and using the function
Code:
Sub Displaydata(ByVal comman As String)
Dim mycommand As SqlCommand
Dim myuserconn As New Data.SqlClient.SqlConnection(System.Configuration. ConfigurationManager.ConnectionStrings("test").ToString)
Try
myuserconn.Open()
mycommand = New SqlCommand(comman, myuserconn)
Dim userdata As SqlDataReader
userdata = mycommand.ExecuteReader()
If userdata.HasRows = True Then
userview.DataSource = userdata
userview.DataBind()
End If
Catch ex As Exception
End Try
totrecords.InnerHtml = "Total Users :" & userview.Rows.Count.ToString
myuserconn.Close()
End Sub
__________________
SELF REALIZATION IS THE FIRST ENCOUNTER WITH REALITY.- Sahajayoga.org
|