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

Smith
Smith
Participant
374 Points
112 Posts

Hi,

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

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

Share:   fb twitter linkedin
Answers
Brian
Brian
Participant
570 Points
75 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