The below QUERY can compare two dates in sql server. In that query CONVERT() function is exist. Date value is changed into varchar data type by using CONVERT() function . Here we change the DATETIME data type into varchar. So we got exact date alone. The query as follows....
SELECT *
FROM Login_Attendance
WHERE (DATEDIFF(day, CONVERT(varchar(10), currdate, 101), CONVERT(varchar(10), '4/25/2008', 101)) = 0)
Here,
101----> denotes the required format(mm/dd/yyyy) of the date
For eg:
currdate='4/25/2008 2:23:34 PM'
Friday, April 25, 2008
Thursday, April 17, 2008
Adding Empty Row to a Data Grid
Here we are going to see how to add empty row in a datagrid. First create an empty Data Row for a Data Table. Assign the Datatable as dataSource for the datagrid. Then bind the datagrid. Code is in VB.Net to add empty row is as follows.
#VB.NET
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt as new DataTable
Dim dr as DataRow
dr = dt.NewRow()
DataGrid1.DataSource = dt
DataGRid1.DataBind()
End Sub
#VB.NET
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt as new DataTable
Dim dr as DataRow
dr = dt.NewRow()
DataGrid1.DataSource = dt
DataGRid1.DataBind()
End Sub
Subscribe to:
Comments (Atom)