Oracle - Convert datetime formatHow do I (or can I) SELECT DISTINCT on multiple columns?How to return only the Date from a SQL Server DateTime datatypeGet list of all tables in Oracle?SQLite - UPSERT *not* INSERT or REPLACEHow do I limit the number of rows returned by an Oracle query after ordering?How can I get column names from a table in SQL Server?SQL Server query - Selecting COUNT(*) with DISTINCTWhat are the options for storing hierarchical data in a relational database?Update a column value, replacing part of a stringOracle SQL query for Date format

What does "determined" refer to in Acts 17v26?

Dates on degrees don’t make sense – will people care?

Extending prime numbers digit by digit while retaining primality

What mathematical theory is required for high frequency trading?

Can you use one creature for both convoke and delve for Hogaak?

Justifying Affordable Bespoke Spaceships

macOS: How to take a picture from camera after 1 minute

Prisoner on alien planet escapes by making up a story about ghost companions and wins the war

How did Gollum enter Moria?

Boss wants someone else to lead a project based on the idea I presented to him

What was the flower of Empress Taytu?

Is the continuity test limit resistance of a multimeter standard?

What are the pros and cons for the two possible "gear directions" when parking the car on a hill?

Second 100 amp breaker inside existing 200 amp residential panel for new detached garage

What was the first third-party commercial application for MS-DOS?

Am I legally required to provide a (GPL licensed) source code even after a project is abandoned?

Is there any proof that high saturation and contrast makes a picture more appealing in social media?

Counterfeit checks were created for my account. How does this type of fraud work?

Why do you need to heat the pan before heating the olive oil?

Why isn't my calculation that we should be able to see the sun well beyond the observable universe valid?

Can Hunter's Mark be moved after Silence has been cast on a character?

I found a password with hashcat, but it doesn't work

Is there a term for the belief that "if it's legal, it's moral"?

Mathematically modelling RC circuit with a linear input



Oracle - Convert datetime format


How do I (or can I) SELECT DISTINCT on multiple columns?How to return only the Date from a SQL Server DateTime datatypeGet list of all tables in Oracle?SQLite - UPSERT *not* INSERT or REPLACEHow do I limit the number of rows returned by an Oracle query after ordering?How can I get column names from a table in SQL Server?SQL Server query - Selecting COUNT(*) with DISTINCTWhat are the options for storing hierarchical data in a relational database?Update a column value, replacing part of a stringOracle SQL query for Date format






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I have a temp table.



It has last_update column in 2/10/2018 6:01:50 PM datetime format.



How can I write THE BEST QUERY to display all information that's updated on 02-Oct-2018 day?










share|improve this question



















  • 1





    use function to_date('02-oct-2018','dd-mon-yyyy')

    – Mebin Joe
    Mar 25 at 7:07






  • 1





    You shouldn't be storing timestamp values in a varchar column to begin with. That is a really bad idea

    – a_horse_with_no_name
    Mar 25 at 7:09

















1















I have a temp table.



It has last_update column in 2/10/2018 6:01:50 PM datetime format.



How can I write THE BEST QUERY to display all information that's updated on 02-Oct-2018 day?










share|improve this question



















  • 1





    use function to_date('02-oct-2018','dd-mon-yyyy')

    – Mebin Joe
    Mar 25 at 7:07






  • 1





    You shouldn't be storing timestamp values in a varchar column to begin with. That is a really bad idea

    – a_horse_with_no_name
    Mar 25 at 7:09













1












1








1








I have a temp table.



It has last_update column in 2/10/2018 6:01:50 PM datetime format.



How can I write THE BEST QUERY to display all information that's updated on 02-Oct-2018 day?










share|improve this question
















I have a temp table.



It has last_update column in 2/10/2018 6:01:50 PM datetime format.



How can I write THE BEST QUERY to display all information that's updated on 02-Oct-2018 day?







sql oracle oracle11g






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 18 at 10:45









user7294900

26.7k123870




26.7k123870










asked Mar 25 at 7:02









leebongeeleebongee

375




375







  • 1





    use function to_date('02-oct-2018','dd-mon-yyyy')

    – Mebin Joe
    Mar 25 at 7:07






  • 1





    You shouldn't be storing timestamp values in a varchar column to begin with. That is a really bad idea

    – a_horse_with_no_name
    Mar 25 at 7:09












  • 1





    use function to_date('02-oct-2018','dd-mon-yyyy')

    – Mebin Joe
    Mar 25 at 7:07






  • 1





    You shouldn't be storing timestamp values in a varchar column to begin with. That is a really bad idea

    – a_horse_with_no_name
    Mar 25 at 7:09







1




1





use function to_date('02-oct-2018','dd-mon-yyyy')

– Mebin Joe
Mar 25 at 7:07





use function to_date('02-oct-2018','dd-mon-yyyy')

– Mebin Joe
Mar 25 at 7:07




1




1





You shouldn't be storing timestamp values in a varchar column to begin with. That is a really bad idea

– a_horse_with_no_name
Mar 25 at 7:09





You shouldn't be storing timestamp values in a varchar column to begin with. That is a really bad idea

– a_horse_with_no_name
Mar 25 at 7:09












3 Answers
3






active

oldest

votes


















2














It is preferable to avoid TRUNC especially if you have an index on the column last_update.
A simple where condition should be better and may be better performant.



WHERE last_update >= date '2018-10-02' AND
last_update < date '2018-10-02' + 1





share|improve this answer






























    3














    You can use trunc function



    select *
    from tab
    where trunc(last_update) = date'2018-10-02'





    share|improve this answer























    • Can you share a docs link for this date formatting?

      – user7294900
      Mar 25 at 7:09






    • 2





      @user7294900 Basic Elements of Oracle SQL

      – a_horse_with_no_name
      Mar 25 at 7:10


















    2














    Use trunc function for getting the same day:



    trunc(last_update) = trunc(to_date('02-Oct-2018', 'DD-MONTH-YYYY'))



    The TRUNC (date) function returns date with the time portion of the day truncated to the unit specified by the format model fmt. The value returned is always of datatype DATE, even if you specify a different datetime datatype for date. If you omit fmt, then date is truncated to the nearest day.




    You can also use format DD-MON-YYYY






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332659%2foracle-convert-datetime-format%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      It is preferable to avoid TRUNC especially if you have an index on the column last_update.
      A simple where condition should be better and may be better performant.



      WHERE last_update >= date '2018-10-02' AND
      last_update < date '2018-10-02' + 1





      share|improve this answer



























        2














        It is preferable to avoid TRUNC especially if you have an index on the column last_update.
        A simple where condition should be better and may be better performant.



        WHERE last_update >= date '2018-10-02' AND
        last_update < date '2018-10-02' + 1





        share|improve this answer

























          2












          2








          2







          It is preferable to avoid TRUNC especially if you have an index on the column last_update.
          A simple where condition should be better and may be better performant.



          WHERE last_update >= date '2018-10-02' AND
          last_update < date '2018-10-02' + 1





          share|improve this answer













          It is preferable to avoid TRUNC especially if you have an index on the column last_update.
          A simple where condition should be better and may be better performant.



          WHERE last_update >= date '2018-10-02' AND
          last_update < date '2018-10-02' + 1






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 25 at 7:30









          Kaushik NayakKaushik Nayak

          24.3k51433




          24.3k51433























              3














              You can use trunc function



              select *
              from tab
              where trunc(last_update) = date'2018-10-02'





              share|improve this answer























              • Can you share a docs link for this date formatting?

                – user7294900
                Mar 25 at 7:09






              • 2





                @user7294900 Basic Elements of Oracle SQL

                – a_horse_with_no_name
                Mar 25 at 7:10















              3














              You can use trunc function



              select *
              from tab
              where trunc(last_update) = date'2018-10-02'





              share|improve this answer























              • Can you share a docs link for this date formatting?

                – user7294900
                Mar 25 at 7:09






              • 2





                @user7294900 Basic Elements of Oracle SQL

                – a_horse_with_no_name
                Mar 25 at 7:10













              3












              3








              3







              You can use trunc function



              select *
              from tab
              where trunc(last_update) = date'2018-10-02'





              share|improve this answer













              You can use trunc function



              select *
              from tab
              where trunc(last_update) = date'2018-10-02'






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Mar 25 at 7:07









              Barbaros ÖzhanBarbaros Özhan

              17.6k71634




              17.6k71634












              • Can you share a docs link for this date formatting?

                – user7294900
                Mar 25 at 7:09






              • 2





                @user7294900 Basic Elements of Oracle SQL

                – a_horse_with_no_name
                Mar 25 at 7:10

















              • Can you share a docs link for this date formatting?

                – user7294900
                Mar 25 at 7:09






              • 2





                @user7294900 Basic Elements of Oracle SQL

                – a_horse_with_no_name
                Mar 25 at 7:10
















              Can you share a docs link for this date formatting?

              – user7294900
              Mar 25 at 7:09





              Can you share a docs link for this date formatting?

              – user7294900
              Mar 25 at 7:09




              2




              2





              @user7294900 Basic Elements of Oracle SQL

              – a_horse_with_no_name
              Mar 25 at 7:10





              @user7294900 Basic Elements of Oracle SQL

              – a_horse_with_no_name
              Mar 25 at 7:10











              2














              Use trunc function for getting the same day:



              trunc(last_update) = trunc(to_date('02-Oct-2018', 'DD-MONTH-YYYY'))



              The TRUNC (date) function returns date with the time portion of the day truncated to the unit specified by the format model fmt. The value returned is always of datatype DATE, even if you specify a different datetime datatype for date. If you omit fmt, then date is truncated to the nearest day.




              You can also use format DD-MON-YYYY






              share|improve this answer





























                2














                Use trunc function for getting the same day:



                trunc(last_update) = trunc(to_date('02-Oct-2018', 'DD-MONTH-YYYY'))



                The TRUNC (date) function returns date with the time portion of the day truncated to the unit specified by the format model fmt. The value returned is always of datatype DATE, even if you specify a different datetime datatype for date. If you omit fmt, then date is truncated to the nearest day.




                You can also use format DD-MON-YYYY






                share|improve this answer



























                  2












                  2








                  2







                  Use trunc function for getting the same day:



                  trunc(last_update) = trunc(to_date('02-Oct-2018', 'DD-MONTH-YYYY'))



                  The TRUNC (date) function returns date with the time portion of the day truncated to the unit specified by the format model fmt. The value returned is always of datatype DATE, even if you specify a different datetime datatype for date. If you omit fmt, then date is truncated to the nearest day.




                  You can also use format DD-MON-YYYY






                  share|improve this answer















                  Use trunc function for getting the same day:



                  trunc(last_update) = trunc(to_date('02-Oct-2018', 'DD-MONTH-YYYY'))



                  The TRUNC (date) function returns date with the time portion of the day truncated to the unit specified by the format model fmt. The value returned is always of datatype DATE, even if you specify a different datetime datatype for date. If you omit fmt, then date is truncated to the nearest day.




                  You can also use format DD-MON-YYYY







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 18 at 10:44

























                  answered Mar 25 at 7:06









                  user7294900user7294900

                  26.7k123870




                  26.7k123870



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332659%2foracle-convert-datetime-format%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                      155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해