Hi All
I want to check whether there is a record present in my database with value:
StartDate="Todays's Date"
where start date is the column name with datatype DATE.

Use PreparedStatement and new Date (using java.sql.Date not java.util.Date).

If you question is how to formulate a query in general, then please find an SQL forum.

If you have a query to fire , then use the SYSDATE as the standard one.
For example, on Oracle if I query as follows,

"select SYSDATE from DUAL", it should get me today's date. You may need to use this as part of your query. I understand you are in the midst of a Java program
So, after your query is built at Java area, you need to use the word "SYSDATE" which Oracle understands. I think it can work on other Databases too. But you may check it once.
Hope this helped.

Hi, Massod Ali,

Pls try the below query

Select * from tablename where startdate = convert(char,getdate(),103)

Thanks&Regards
Sakthimeenakshi.S

Hi All
I want to check whether there is a record present in my database with value:
StartDate="Todays's Date"
where start date is the column name with datatype DATE.

Another way with sysdate is:

select * from table where StartDate = sysdate

or better the following will check only the date without taking into account the hours, minutes:

select * from table where  trunc(StartDate) = trunc(sysdate)

With the first, these dates will be unequal:
27/07/2009 12:00:00 , 27/07/2009 12:00:01

but with the second query only the year, month, day will be compared

Ok, If you want to compare two datetime, you need not to convert the getdate() into date.

Try the below query in SQL Server,

select * from table where startdate = getdate()

I hope, it will be usefull for you...

Thanks & Regards

Sakthimeenakshi.S

Another way with sysdate is:

select * from table where StartDate = sysdate

or better the following will check only the date without taking into account the hours, minutes:

select * from table where  trunc(StartDate) = trunc(sysdate)

With the first, these dates will be unequal:
27/07/2009 12:00:00 , 27/07/2009 12:00:01

but with the second query only the year, month, day will be compared

This article has been dead for over six months. Start a new discussion instead.