Brian,
There are a few ways to do this.
// first get java.util.Date object
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, 2002);
c.set(Calendar.MONTH, 1);
c.set(Calendar.DATE, 17);
java.util.Date date = c.getTime();
// Option 1. Using java.sql.Date
Criteria crit = new Criteria();
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
crit.add(MyTable.DATE, sqlDate, Criteria.LESS_THAN);
// Option 2. Using SimpleDateFormat
java.text.SimpleDateFormat sdf = new
java.text.SimpleDateFormat("yyyy-MM-dd");
Criteria crit = new Criteria();
crit.add(MyTable.DATE, sdf.format(date), Criteria.LESS_THAN);
The first option relies on the java.sql.Date object toString method which
formats the date as yyyy-MM-dd. The second option just explicitly sets the
string.
Joel
> -----Original Message-----
> From: Brian Kidney [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 13, 2002 9:26 AM
> To: turbine-user
> Subject: Criteria and dates?
>
>
> Hi, can the following SQL command be constructed using criteria?
>
> SELECT *
> FROM MyTable
> WHERE Date < '2002-01-17'
>
> Where the Date is a MSSQL date column.
>
> Brian Kidney
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>