For converting date-time to only date

If you want to convert date-time to date only in sql query then you use the following function:
for example you have 2 parameters ''StartDate" and "EndDate"  firse declare them...
-----------------------------------------------------------------------------------


@StartDate datetime,
@EndDate datetime


SELECT  *


where  tablename.Startdate >=convert(varchar, @StartDate, 102)
and tablename.enddate <=convert(varchar, @EndDate, 102)
-----------------------------------------------------------------------------------
**************************Explanation **************************

@StartDate datetime = Declaration of parameter StartDate
@EndDate datetime = Declaration of parameter EndDate


convert(varchar, @StartDate, 102) = function of converting date-time to date
 tablename.Startdate >=convert(varchar, @StartDate, 102) = Proper syntax of function

Comments

Popular posts from this blog

TSQL To Get All the Names of tables and Databases whose data have changed in last 24 Hours

To Get All the Names of tables and Databases their data have changed in last 24 Hours And Backup those databases

Apply paging in procedure