| Author |
Topic |
|
jonasdavedomingo
Starting Member
33 Posts |
Posted - 2004-10-28 : 09:16:42
|
i have 2 SQL queries:query1 = "SELECT DATEDIFF(dd, (convert(datetime), '10-24-2004 12:33:00 PM'), (convert(datetime), '10-24-2004 12:33:00 PM')) FROM table;query2 = "SELECT DATEDIFF(dd, (convert(datetime), '10-24-2004 12:33:00 PM'), (convert(datetime), '11-24-2004 12:54:00 PM')) FROM table; query1 is working but query2 is not working. if u will notice, the only difference is the month. query1 is month 10 while query 2 is month 11.what seems to be the problem? this is a weird problem i think. |
|
|
surefooted
Posting Yak Master
188 Posts |
Posted - 2004-10-28 : 09:29:08
|
[code]Select datediff(dd, (convert(datetime, '10-24-2004 12:33:00 PM')), (convert(datetime, '11-24-2004 12:33:00 PM'))) From Table[/code]-JonShould still be a "Starting Member" . |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-10-28 : 09:45:12
|
| What's "not working" ? YOu get an error? you get a value you don't expect?- Jeff |
 |
|
|
jonasdavedomingo
Starting Member
33 Posts |
Posted - 2004-10-28 : 19:23:02
|
ooops, sorry typo error. i mean SELECT DATEDIFF(dd, convert(datetime, '10-24-2004 12:33:00 PM'), convert(datetime, '10-24-2004 12:33:00 PM')) SELECT DATEDIFF(dd, convert(datetime, '10-24-2004 12:33:00 PM'), convert(datetime, '11-24-2004 12:54:00 PM')) ___________________________ if i do query1 then there's no error. i mean it works and it can get the difference of the two dates. but if i do query2, an error appears saying java.sql.SQLException: No data foundthis problem is weird, i dont know why error error occurs if i do query2. the only difference is i changed the month October\ which is 10 to month November which is 11. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-10-28 : 19:26:07
|
| Both of these work for me in Query Analyer. So the problem is outside of SQL Server. The problem must be on the front-end side, maybe with the JDBC driver that you are using.Tara |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-10-28 : 19:27:18
|
Have you tried running each statement separately? It could be the query is fine but the Java interface is causing the error. Also try switching the two around and see if the error happens. It could be that Java is only expecting one statement at a time. Yeah, what she said! You had five months to catch up Tara, are you gonna let me answer a few now? |
 |
|
|
jonasdavedomingo
Starting Member
33 Posts |
Posted - 2004-10-29 : 01:57:43
|
| tduggan: i really dont know what seems to be the problem. it's kinda weird.robvolk: yeh i tried it separately and there's still an error. |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-10-29 : 03:05:10
|
quote: Originally posted by jonasdavedomingo ooops, sorry typo error. i mean SELECT DATEDIFF(dd, convert(datetime, '10-24-2004 12:33:00 PM'), convert(datetime, '10-24-2004 12:33:00 PM')) SELECT DATEDIFF(dd, convert(datetime, '10-24-2004 12:33:00 PM'), convert(datetime, '11-24-2004 12:54:00 PM')) ___________________________ if i do query1 then there's no error. i mean it works and it can get the difference of the two dates. but if i do query2, an error appears saying java.sql.SQLException: No data foundthis problem is weird, i dont know why error error occurs if i do query2. the only difference is i changed the month October\ which is 10 to month November which is 11.
are you by any chance using the datediff result as criteria to another query and this query will not return any data coz the criteria was not met?--------------------keeping it simple... |
 |
|
|
jonasdavedomingo
Starting Member
33 Posts |
Posted - 2004-10-29 : 18:22:52
|
| No. i execute it separately. the two queries are not dependent. |
 |
|
|
jonasdavedomingo
Starting Member
33 Posts |
Posted - 2004-10-29 : 22:50:51
|
| stupid me stupid me stupid me!!!! argghhhhhhhhhhhhhi already made it and it worked.thanks God. wohoooo......sorry for the disturbance |
 |
|
|
|