Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to compare sql date

 
arvind kushwaha
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Team,

I have one table...in which data is stored along with date and time...i want to retrieve the data based on current date..

But as in table data is stored with date time...I am unable to retrieve it...Please help me out ...ITs urgent!!!


i am writing query....Select * from securities where updatedfields='curdate()' but in updated fields data is stored like 2011-8-18 10:55:14 in this format i want to retrieve the data based on date.
 
Sudheer Bhat
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to select those rows which are updated today, then why don't you use "updatedfields = sysdate"? I assume that the datatype of updatedfields is DATE.


 
arvind kushwaha
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear team,,


the datatype for updatedfields is datetime...so that why its not working..
 
Sudheer Bhat
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am no expert in MYSQL ( I think your DB is MYSQL since Oracle doesn't have a DATETIME datatype), this is what I came up after referring to mySQL manual.


Where test is a table and it has test column of datatype datetime.
 
arvind kushwaha
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks sudhir...It working now....Thanks you so much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic