Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8850045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:48:30+00:00 2026-06-14T12:48:30+00:00

select now() will output 2012-11-20 09:05:38 . select substr(now(), locate(‘ ‘, now())) will output

  • 0

select now() will output 2012-11-20 09:05:38.

select substr(now(), locate(' ', now())) will output 09:05:38.

How can I obtain this result: 2012-11-20 instead? Been there, done that but can’t achieve it yet. Forgive me for my lacking but please help me. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:48:32+00:00Added an answer on June 14, 2026 at 12:48 pm

    Not an specific answer to your question about substrings, but if I wanted the DATE part of NOW() I would do:

    SELECT DATE(NOW());
    

    Or for the time portion

    SELECT TIME(NOW());
    

    For actual string purposes though you can use:

    SUBSTR('SOME STRING', 0, LOCATE(' ', 'SOME STRING')) <- returns from position zero for a length of 4 characters
    

    Or

    SUBSTRING_INDEX('SOME STRING', ' ', 1) <- gives 'SOME'
    SUBSTRING_INDEX('SOME STRING', ' ', -1) <- gives 'STRING'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this right now: <%= f.select :credit, (0..500) %> This will result in
I need to convert now() to GMT0. SELECT now(); should output current time in
after mysql> select now() got 2012-03-29 14:07:10 if 5 minutes is my interval, so,
this is my code for now: SELECT id, number FROM Media WHERE user =
Right now I'm doing this: SELECT * FROM messages WHERE location_id = 7 AND
now i use this code: $welcome_text = mysql_query(SELECT * FROM `text` WHERE `name` =
I can select the first item in the div using $('.class:first') Now since I
I am planning a following html output with PHP. Now when I select week,
my table has the following fields videos |id| |average| |views| now i select some
SELECT SUM(bytes),stamp_updated from acct where stamp_updated BETWEEN datetime('now', 'localtime','-7 hours') AND datetime('now', 'localtime') GROUP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.