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

Smith
Smith
Participant
360 Points
110 Posts

Hi,

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

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

Share:   fb twitter linkedin
Answers
Brian
Brian
Participant
536 Points
73 Posts
Marked as answer      

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
banner

Blog

Active User (0)

No Active User!
 Log In to Chat