ullas
ullas

Reputation: 1

Comparing two date of varchar and getdate

I have a database table field named User_Created_Date of type Varchar.I want to write a query to fetch all records where the difference between Today's date and User_Created_Date is greater than 31 days

pls help

Upvotes: 0

Views: 93

Answers (1)

Frédéric Hamidi
Frédéric Hamidi

Reputation: 262939

Since your VARCHAR column's date format is DD/MM/YY, use:

select * from Your_Table
where DATEDIFF(day, CONVERT(datetime, User_Created_Date, 3), GETDATE()) > 31;

Upvotes: 1

Related Questions