SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    MSYQL STR_TO_DATE

    Hello,

    Code:
    <?php
    $query="SELECT * FROM sms_logs 
               WHERE empno='$empno' 
               AND STR_TO_DATE(LEFT(date,10),'%Y/%m/%d')=....";
    ?>
    my question is, the first parameter LEFT(date,10) of STR_TO_DATE() need to be enclosed by 's ?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by afridy View Post
    my question is, the first parameter LEFT(date,10) of STR_TO_DATE() need to be enclosed by 's ?
    what happened when you tested it? ™
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    what happened when you tested it? ™
    could not see any different it seems

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by afridy View Post
    could not see any different it seems
    o rly?

    please show the actual query you ran with the quotes around LEFT(date,10)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    o rly?

    please show the actual query you ran with the quotes around LEFT(date,10)
    I am sorry! just tested again and it does not have to be enclosed by '. if i did , then no out put (no errors shown though).
    tx r937


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •