• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

sql syntax for system date

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic