Subject Re: [Firebird-Java] Inserting only date-part of timestam with Jaybird and Hibernate
Author Mark Rotteveel
> Hi,
> I am not 100% sure this is related to Firebird/Jaybird, so forgive me in
> case I'm wrong.
> I am inserting a row with hibernate, and for setting a date column
> (Timestamp in sql) to today I use:
> record.setCreationDate( new java.util.Date() );
> This works generally, but includes the time-part (16.11.2010 15:27:24),
> whereas I would only want the date (16.11.2010)
> Does anyone know how to fix this?

There are a number of ways (in order of 'best' to 'worse'):
1) Use DATE as your column type if you are not interested in the time portion, not TIMESTAMP; TIMESTAMP is simply the wrong type for this
2) Set the time portions to zero
3) Use java.sql.Date, not java.util.Date (java.sql.Date does not store time portion)
4) Add a trigger to normalize the TIMESTAMP value by cutting off time information (eg by casting to DATE)

Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
Jetzt De-Mail-Adresse reservieren: