• Post Reply Bookmark Topic Watch Topic
  • New Topic

SQL SUBSTRING command problem

 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's OK, I've sorted it (it's Friday), the substring has to be from 1,8 NOT 0,8
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!