This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQL SUBSTRING command problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL SUBSTRING command problem" Watch "SQL SUBSTRING command problem" New topic
Author

SQL SUBSTRING command problem

Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
Quite simple really, I have a table with a shift_id which is generated by date (ddmmyyyhhmmss) plus '_userid' (example 24032006132015_01). I need to check that a user doesn;t have a shift time for today already entered, so I'm checking the substring of the first 8 characters to see if they match todays date, here is my SQL command:

[SELECT * FROM tblTimeSheet WHERE (SUBSTRING(shift_id, 0, 8) = '24032006')]

So how come this returns NULL when there are clearly 5 rows in my DB which have 24032006 at the start of the shift_id?


Cheers!
Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
It's OK, I've sorted it (it's Friday), the substring has to be from 1,8 NOT 0,8
 
wood burning stoves
 
subject: SQL SUBSTRING command problem
 
Similar Threads
Ksh script
date problem
String to byte? and string to byte[]?
How to add a new attribute via xsl in an existing xml structure
I want to evalutate the cents field.