Hi scott, you can use datetime or timestamp. Using timestamp in this example shows you that now() can be a default or inserted value. You can also use current_tiumestamp.
Other functions like date_add can help you to look for rows verifying interval days like in this example : mysql> create table dates(id int, d timestamp default now()); Query OK, 0 rows affected (0.06 sec) mysql> insert into dates(id) values(1); Query OK, 1 row affected (0.03 sec) mysql> insert into dates(id) values(2); Query OK, 1 row affected (0.02 sec) mysql> select * from dates; +------+---------------------+ | id | d | +------+---------------------+ | 1 | 2005-06-13 10:22:47 | | 2 | 2005-06-13 10:22:50 | +------+---------------------+ 2 rows in set (0.00 sec) mysql> select date_add(d,interval 2 day) from dates; +----------------------------+ | date_add(d,interval 2 day) | +----------------------------+ | 2005-06-15 10:22:47 | | 2005-06-15 10:22:50 | +----------------------------+ 2 rows in set (0.05 sec) Clearer info in dev.mysql.com/doc about timestamp and datetime. mysql> hope that helps. Mathias Selon Scott Purcell <[EMAIL PROTECTED]>: > Hello, > > I would like to do the following: I am creating a site where people can add > items to a cart. In order to keep items for [X] amount of days, I would like > to create a database table in mysql to hold a 'itemRef' and a 'Date'. Then in > a relationship table I can hold the 'itemRef' and 'items' they have choosen. > I think this would be simple. > > But there are a lot of choices for the date field. I would like a date field > that I can insert a now() or something, when I insert. And then later, > through Java code, query and find all dates that are greater than [X] amount > of days, and delete them to keep the database clean? > > So my question would be, > > A) which date type field should I create. > B) how to insert now() > C) can I run one query to find out if the date field is greater than [X] > days? > > Any help would be appreciated. > Sincerely > Scott > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]