Click to See Complete Forum and Search --> : How to us now function within sql


hind_0a0
May 13th, 2006, 04:27 AM
hello brothers

how ar u doing...

i want make sql query to retrive the record or records that the enddate = today date

i use now function but could not get the correct answer


sql : select * from emp where enddate=now ;

but no result i got


please help


bye

olivthill
May 13th, 2006, 05:55 AM
Hello, Sir.

First, you need to learn how to use the "shift" key, so that the first character of the first word of each sentence is printed in upper case.

Then, you need to tell us which programming language you are using, because each database has its own way of dealing with dates and time.
Is it SQL for Oracle? SQL for Access? SQL for MySQL? SQL for Postgres? SQL for Sybase? SQL for SQL Server? etc.

In SQL for Oracle, you would have:SELECT .... WHERE TRUNC(enddate)=TRUNC(SYSDATE);In SQL for Access, you would have:SELECT .... WHERE Format(enddate, "y/m/d")=Format(now(),"y/m/d");

pweegar
May 16th, 2006, 10:35 AM
And in SQL Server 2000, you would use the getdate() function. However, this will return the current date and time, so you may have to parse out the date part.