Click here to Skip to main content
16,017,247 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a table related to payments.
I need to search on daily basis
but it is in "2012-04-01 13:00:30.687" date format
column name is PaymentDate
i am able to search by year.
but i need by date
Please help me
i am using
SQL
select * from online_payments where PaymentDate like '%2012%'

this is giving whole year results but i need only particular date.
I tried but not able to find.
Its some what urgent now.
Can any one help me please.
Posted
Updated 1-Apr-12 21:44pm
v3

Try:
SQL
SELECT * FROM Student WHERE dat2 >= '2012-02-12' and dat2 < '2012-02-13'
 
Share this answer
 
Have a look at the CONVERT command. http://msdn.microsoft.com/en-us/library/aa226054(v=sql.80).aspx[^]

With this command you do your query like this:

SQL
select * from online_payments where CONVERT(varchar(8), PaymentDate,112) = '20120401'


regards
Michel
 
Share this answer
 
Try like below.

SQL
select * 
from online_payments 
where DateAdd(day, DateDiff(day, 0, PaymentDate), 0) = '2012-04-01'


DateAdd(day, DateDiff(day, 0, PaymentDate), 0) removes time and get the date alone
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900