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.  [ 4 posts ] 
Author Message
 Post subject: Problems with datetime using createSql()
PostPosted: Fri Jul 07, 2006 10:14 am 
Newbie

Joined: Fri Jul 07, 2006 9:53 am
Posts: 11
Im trying to do a query that recieves visitors from a table between 2 dates. However, Im getting an error saying:


Caused by: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting datetime from character string.

I understand the fact that it says its caused by java.sql.SQLException, but here are the strange parts. This is the day format that im trying to get working.

sch_in_time >= '2006-07-07 00:00:00.000' and sch_out_time <='2006-07-07 23:59:59.000'

This throws that error. But if i cut/paste the query into query analyzer, everything works just fine. Also, if i have a date in the format of '2006-07-07 23 PM', it works just fine. This would almost be useable except it would leave people that were there between 11pm and 11:59pm.

Another tidbit of data is that im using the createSQL method in order to call this.

If anyone could give me some pointers, I would be extremely grateful. Thank you for your time.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 11:59 am 
Newbie

Joined: Tue Jul 04, 2006 9:58 am
Posts: 15
Why don't you try this:
sch_in_time BETWEEN '2006-07-07' and '2006-07-08' which is exactly the same?
'2006-07-08' normally mean '2006-07-08 00:00:00.000' and in fact
( sch_in_time < '2006-07-08' ) means same as '2006-07-07 23:59:59.999'


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 12:25 pm 
Newbie

Joined: Fri Jul 07, 2006 9:53 am
Posts: 11
unfortunately id have to check against sch_in_time and sch_out_time :(

the between idea would almost work but since people can be scheduled across multiple days (monday through friday), i dont want it crossing over with other people so i couldnt really do a:

(sch_in_time between 7/7/06 and 7/15/06 ) and (sch_out_time between 7/7/06 and 7/15/06)


Top
 Profile  
 
 Post subject: Problem with createSQLQuery
PostPosted: Wed Aug 30, 2006 6:02 am 
Newbie

Joined: Wed Aug 30, 2006 5:57 am
Posts: 1
Hi tont,
May i know whether u had find a solution for the problem u faced? I face the same the problem now and hope u can provide the solution for me. Thanks a lot....:)

Best regrads,
Suanne


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.