-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: How to use trunc() function?
PostPosted: Fri Mar 10, 2006 2:20 pm 
Beginner
Beginner

Joined: Wed Apr 27, 2005 8:27 am
Posts: 27
Hi everybody,

I have to extract just the date (without the hour) from a field of the database.
I think I should use trunc(), don't I?
I've tried trunc(dt, 'dd/MM/yyyy') but it did not work, resulting in an WARN RequestProcessor:516 - Unhandled Exception thrown: class org.hibernate.exception.SQLGrammarException

Can anybody help me to solve this?

thanks, Guilherme


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 10, 2006 9:48 pm 
Beginner
Beginner

Joined: Wed Nov 30, 2005 2:41 pm
Posts: 29
what database? I think not all TRUNCs are the same. Here's an Oracle example:
TRUNC(SYSDATE)
...returns current date at (preceding) midnight. Their format strings are 'DD', or 'YEAR', etc.
TRUNC(SYSDATE,'YEAR')

If you're using something else, just google "sql trunc" and your database name.

--------------------
pls rate if helpful!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.