• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

help with mysql query

I need records of the employees who joined today and I am using this query

select * from emp where join_date between '2010-01-07 00:00:00' AND '2010-01-07 23:59:59'

I need help to change this query such that I don't have to manually change the date every day
0
mkarthik415
Asked:
mkarthik415
  • 4
  • 2
  • 2
  • +2
1 Solution
 
shru_0409Commented:
select * from emp where join_date = trunc(sysdate)
0
 
Johnner_dkCommented:
In asp:

dim start_date
dim end_date

 start_date  = year(now)&"-"&month(now)&"-"&day(now)&" "&hour(now)&":"&minute(now)&":"&second(now)

end_date  = year(now)&"-"&month(now)&"-"&day(now)&" 23:59:59"

select * from emp where join_date between "&start_date&"' AND '"&end_date&"'
0
 
mkarthik415Author Commented:
when using
select * from emp where join_date = trunc(sysdate)

I am getting error 'trunc does not exist'
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Johnner_dkCommented:
what programming language are you using?
0
 
shru_0409Commented:
is not oracle???

in mysql try this...

select * from emp where join_date = CURDATE();
0
 
mkarthik415Author Commented:
The programming language I am using is java.
0
 
SharathData EngineerCommented:
What is the database you are working on ?
0
 
mkarthik415Author Commented:
My database is MySql
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you will need this:

select * from emp where join_date >= CURDATE() and join_date < DATE_ADD(CURDATE(), INTERVAL 1 DAY);
0
 
mkarthik415Author Commented:
TY
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now