Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sql syntax for system date

 
ammuswar kumar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry guys i know that this is not the riight place to put this quest
but i hope u understand
what is the syntax in sql to compare the date(field from table) with the system date(host)
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know of a "standard" sql procedure, but most databases have their own way of doing this:
Oracle- use date math(sysdate - hiredate)
Access- use the dateDiff(sysdate, hiredate) function.
if the answer returns 0 then the it is the same day.
note: This will cause portablility problems between different databases. If you can live with that, check your database documentation for date functions/math.
Jamie
Jamie
[This message has been edited by Jamie Robertson (edited August 20, 2001).]
 
ammuswar kumar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi jamie
thanks for showing me the way,i am obliged but need some more clarification
 
ammuswar kumar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi jamie
tell me if this is correct
select * from table
where date =sysdate;
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>"hi jamie
>tell me if this is correct
>select * from table
>where date =sysdate;"
well that all depends how accurate you want it. That would be true in Oracle if the dates were equal to the millisecond!
to compare to the nearest day, you have to use the truncate function-->this will return all values where hiredate is equal to the system date(at the day level)
"select * from table where trunc(hiredate)=trunc(sysdate)"

Jamie

[This message has been edited by Jamie Robertson (edited August 20, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic