compare the date with hour,minutes,seconds [Resolved]

Posted by Dn2010 under ASP.NET on 4/5/2012 | Points: 10 | Views : 2043 | Status : [Member] | Replies : 5
hi friends,

how to write this query,

select * from emp where calldate > '2012-04-04 22:10:55.000' Order By calldate desc limit 20";

eg

22:10:55.000
2012-04-04 22:10:55.000

it checks only date but i want to filter select records it must be compare also the date with hour,minutes,seconds
,(date and time).
select * from emp where calldate > '2012-04-04 22:10:55.000' Order By calldate desc limit 20";


select * from emp where calldate > '2012-04-04 22:10:55.000' Order By calldate desc limit 20";

please give the correct solution.
thanks.




Responses

Posted by: Savariya on: 4/6/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
cHANGE THIS IN YOUR CODE GIVE DATE_FORMAT TO YOUR DATABASE FIELD ALSO


SELECT DATE_FORMAT(calldate,'%Y%-%m-%d %H:%I:%s.000') as calldate,uname from emp where DATE_FORMAT(calldate,'%Y%-%m-%d %H:%I:%s.000')> '2012-04-04 22:10:55.000' Order By calldate desc limit 20";



THANKS

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 4/5/2012 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi dn2010,


Go with this link it's help us u . .

http://demiliani.com/blog/archive/2006/01/19/3384.aspx
http://stackoverflow.com/questions/10825/howto-compare-a-date-string-to-datetime-in-sql-server

Best Regard's
Prabhakar

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 4/5/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Check this link.It may be useful
http://bytes.com/topic/sql-server/answers/583534-filtering-parts-date-time-field

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dn2010 on: 4/6/2012 [Member] Starter | Points: 25

Up
0
Down
thanks,

but,


this query mysql in asp.net.

SELECT DATE_FORMAT(calldate,'%Y%-%m-%d %H:%I:%s.000') as calldate,uname from emp where calldate > '2012-04-04 22:10:55.000' Order By calldate desc limit 20";



its check > only date,(2012-04-04)

but i want to check with date and time 2012-04-04 22:10:55.000

pls give the correct solution,

thanks.

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dn2010 on: 4/6/2012 [Member] Starter | Points: 25

Up
0
Down
thanks...................

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response