Compare a input date with the inserted date time in sql server

Smith
Smith
2890 Points
78 Posts

Hi,

I want to compare a input date with the inserted date time in sql server.

Views: 9551
Total Answered: 1
Total Marked As Answer: 1
Posted On: 31-Jul-2015 04:40

Share:   fb twitter linkedin
Answers
Brian
Brian
2376 Points
13 Posts
         

Hi Smith,

Suppose you get the date from input field as format MM/dd/yyyy.

You can directly compare in sql query with string date format MM/dd/yyyy ie 12/25/2015 as:

SELECT <FIELDNAME> FROM <TABLENAME> WHERE CONVERT(DATETIME,CONVERT(VARCHAR,<DATEFIELD>,101))='12/25/2015'
Posted On: 01-Aug-2015 23:05
 Log In to Chat