Link to home
Start Free TrialLog in
Avatar of mkarthik415
mkarthik415

asked on

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
Avatar of shru_0409
shru_0409
Flag of India image

select * from emp where join_date = trunc(sysdate)
Avatar of Johnner_dk
Johnner_dk

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&"'
Avatar of mkarthik415

ASKER

when using
select * from emp where join_date = trunc(sysdate)

I am getting error 'trunc does not exist'
what programming language are you using?
is not oracle???

in mysql try this...

select * from emp where join_date = CURDATE();
The programming language I am using is java.
Avatar of Sharath S
What is the database you are working on ?
My database is MySql
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
TY