Doubt to_char

Could someone explain to me the meaning of:

To_char(hire_date-1,'d')

The question is:

Create a query that displays the emp surname, hire_date and the day began. The label for the Date column.
Sort the results by the day of the week from Monday.

Soln:

Select last_name, hire_date, TO_CHAR (hire_date, 'DAY') DAY
employees
order by TO_CHAR (hire_date-1, 'd');

How does the order of?

Hello

Try to view the expression did you place your order BY and see:

select        last_name
,       hire_date
,       TO_CHAR (hire_date, 'DAY')      AS DAY
,       TO_CHAR (hire_date - 1, 'd')     AS order_by_exp          -- For testing only
from        employees
order by  TO_CHAR (hire_date - 1, 'd');

To_char ("dt," d ") returns '1' if dt is a Sunday,"2"If dt is a Monday,...,"7"If dt is a Saturday (depending on your settings for NLS_TERRITORY).
If you would be perfect for ORDER BY Sunday come first, but you want the first come Monday (1 day later). So if you subtract 1 day from dt and use
To_char (dt - 1, '), then you'll have an expression that returns the value '1' if dt is a Monday (and therefore, dt-1 is a Sunday), "2" If dt is a Tuesday (and dt-1 is a Monday),..., "7" If dt is a Sunday (dt-1 Saturday) and (depending on your settings for NLS_TERRITORY).

Tags: Database

Similar Questions

  • Doubt function to_char (date, 'month')

    Hello

    Hope you have a great day.

    I have an installation of forms (Forms11gr2 11.1.2.2 64 bit on Red Hat EL 6 64 bit) where I have a forms module, where I am using the following code, which should return the name of the month in Spanish but he returns in English:

     RESULTADO := TO_CHAR(TO_DATE('10/10/2014','DD/MM/YYYY'),'MONTH');
    

    If I run the previous code on SqlDeveloper, it returns the month in Spanish without problem, but it seems that I should do something else either on the side of Weblogic.

    The database version is 11.2.0.3 64 bit.

    What should I do?

    Concerning

    Carlos

    You must set the NLS_LANG variable in your EPS file ("default.env" If you don't change it) on the appropiately weblogic server.

  • doubt, querying with dates

    Hi all, I have a doubt, a sql statement that includes the date of the interrogation.
      1  SELECT rsh.shipment_num "File#"
      2        ,mmt.transaction_date "Transaction Date"
      3  FROM rcv_shipment_headers rsh,
      4       ap_suppliers aps,
      5    po_headers_all pha,
      6    po_lines_all pla,
      7    mtl_system_items_kfv msi,
      8    rcv_shipment_lines rsl,
      9    rcv_transactions rcv,
     10    mtl_material_transactions mmt,
     11    mtl_transaction_types mtt
     12  WHERE rsh.vendor_id = aps.vendor_id
     13  AND pha.po_header_id = pla.po_header_id
     14  AND pla.item_id = msi.inventory_item_id
     15  AND pha.po_header_id = rsl.po_header_id
     16  and pla.po_line_id = rsl.po_line_id
     17  AND rsl.shipment_header_id = rsh.shipment_header_id
     18  AND rsl.item_id = msi.inventory_item_id
     19  AND rsl.to_organization_id = msi.organization_id
     20  AND rcv.shipment_header_id = rsh.shipment_header_id
     21  AND rcv.organization_id = msi.organization_id
     22  AND rcv.po_header_id = pha.po_header_id
     23  AND rcv.po_line_id = pla.po_line_id
     24  --and pla.org_id = msi.organization_id
     25  AND rsh.SHIPMENT_NUM = 'AP1005'
     26  --AND mmt.transaction_date = TO_CHAR(TO_DATE('14-SEP-2012','DD-MON-YYYY'))
     27  AND rcv.transaction_type = 'DELIVER'
     28  AND rcv.source_document_code = 'PO'
     29  --AND rcv.subinventory = 'Vessel'
     30  AND mmt.rcv_transaction_id = rcv.transaction_id
     31  AND mmt.transaction_type_id = mtt.transaction_type_id
     32* AND rcv.organization_id = 81
    SQL> /
    
    File#                          Transacti
    ------------------------------ ---------
    AP1005                         14-SEP-12
    AP1005                         14-SEP-12
    Now the date of passage
      1  SELECT rsh.shipment_num "File#"
      2        ,mmt.transaction_date "Transaction Date"
      3  FROM rcv_shipment_headers rsh,
      4       ap_suppliers aps,
      5    po_headers_all pha,
      6    po_lines_all pla,
      7    mtl_system_items_kfv msi,
      8    rcv_shipment_lines rsl,
      9    rcv_transactions rcv,
     10    mtl_material_transactions mmt,
     11    mtl_transaction_types mtt
     12  WHERE rsh.vendor_id = aps.vendor_id
     13  AND pha.po_header_id = pla.po_header_id
     14  AND pla.item_id = msi.inventory_item_id
     15  AND pha.po_header_id = rsl.po_header_id
     16  and pla.po_line_id = rsl.po_line_id
     17  AND rsl.shipment_header_id = rsh.shipment_header_id
     18  AND rsl.item_id = msi.inventory_item_id
     19  AND rsl.to_organization_id = msi.organization_id
     20  AND rcv.shipment_header_id = rsh.shipment_header_id
     21  AND rcv.organization_id = msi.organization_id
     22  AND rcv.po_header_id = pha.po_header_id
     23  AND rcv.po_line_id = pla.po_line_id
     24  --and pla.org_id = msi.organization_id
     25  --AND rsh.SHIPMENT_NUM = 'AP1005'
     26  AND mmt.transaction_date = TO_CHAR(TO_DATE('14-SEP-2012','DD-MON-YYYY'))
     27  AND rcv.transaction_type = 'DELIVER'
     28  AND rcv.source_document_code = 'PO'
     29  --AND rcv.subinventory = 'Vessel'
     30  AND mmt.rcv_transaction_id = rcv.transaction_id
     31  AND mmt.transaction_type_id = mtt.transaction_type_id
     32* AND rcv.organization_id = 81
    SQL> /
    
    no rows selected
    Can someone pls suggest me where I am doing wrong.

    Any help is appreciated,
    Thanks in advance

    You can try the below

    AND trunc(mmt.transaction_date) = TO_DATE('14-SEP-2012','DD-MON-YYYY')
    

    I hope that your column is DATE data type. You need not use to_char. When you use a STRING comparison will happen.

    More on the date of your field is assigned a part of the TIME. You must trucate the time part.

    Or if you plan to use the index on the DATE column, you can write it as

    AND mmt.transaction_date between TO_DATE('14-SEP-2012','DD-MON-YYYY') and TO_DATE('14-SEP-2012 23:59:59','DD-MON-YYYY hh24:mi:ss')
    
    Edited by: jeneesh on Sep 14, 2012 5:19 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    
  • To_Number doubt

    Hi once again, EMSI,
    I have this doubt, always on implicit conversions... (!!!!)
    I read the book SQL Fundamentals 1 corrected to prepare for the exam, at the end of each chapter there are a few questions to prove your understanding and a few pages later he has the answers. There is this question:

    What value is returned after executing the next statement?

    SELECT TO_NUMBER (1234.49, '999999.9') FROM DUAL;

    This query generates an error because "education is trying to convert a number using a mask of incompatible format. "If the expression was TO_NUMBER (1234,49, '999999.99') number would return.
    My question is: WHY?
    TO_NUMBER function gets a string as the first parameter, then it implicitly converts 1234.49 to '1234.49', shouldn't around it up to the first decimal digit and 1234.5 back?
    just as would a to_char?

    Thank you

    Paolo

    Hi, Paolo.

    955202 wrote:
    ... This query generates an error because "education is trying to convert a number using a mask of incompatible format. "If the expression was TO_NUMBER (1234,49, '999999.99') number would return.
    My question is: WHY?
    TO_NUMBER function gets a string as the first parameter, then it implicitly converts 1234.49 to "1234.49."

    Exactly! If you use the wrong data type, Oracle will do an implicit conversion, when possible.

    shouldn't it round to the first decimal digit and 1234.5 back?
    just as would a to_char?

    To_char rounds the number, as you said, but only if you explicitly tell him how much of numbers that you want after the comma, like this:

    SELECT     TO_CHAR (1234.49, '999999.9')     AS explicit_result
    FROM     dual;
    

    Output:

    EXPLICIT_RESULT
    ---------------
       1234.5
    

    But you're not explictly tell how many digits you want. You're not explictly calling TO_CHAR at all; you call it implictly, as if your were doing that:

    SELECT     TO_CHAR ('1234.49')          AS implicit_result
    FROM     dual;
    

    Output:

    IMPLICIT_RESULT
    ---------------
    1234.49
    
  • Behavior of $ facsimile in function TO_CHAR

    Hello
    SELECT status_cid,
               LENGTH (status_cid) len, 
               TO_CHAR (status_cid, '$99') status_cid_1,
               LENGTH (TO_CHAR (status_cid, '$99')) len_1
      FROM status
    
    Result 
    
    STATUS_CID     LEN     STATUS_CID_1     LEN_1
    1     1       $1     4
    15     2      $15     4
    Length of the column in the table number iis-status_cid (3).

    My doubt is why there are spaces in the alias column status_cid_1 while $ facsimile is used in the function to_char top of the query.

    Thanks in advance.

    Kind regards
    Prakash

    That's the negative symbol

    a number can be negative...

    http://Nuijten.blogspot.com/2011/09/quick-how-long-is-this-string.html

    Published by: Alex Nuijten on March 19, 2012 13:21

  • some doubts in the conversion of oracle query

    I have to convert the following query in ms access to oracle.

    INSERT INTO the Bill (Reffacture, InvoiceDesc)
    Select a_Invoices! [Ref provider] & "-" & Trim (a_Invoices! [invoice No.]) & "Q" & DatePart ("q", [invDate]) & "-" & DatePart("yyyy",[invDate]) & "SB" as Reffacture.
    Trim (a_Invoice_Desc! [Invoice line Description]) AS a Expr4
    Of a_Invoices a_Invoice_Desc INNER JOIN
    WE (a_Invoices. [Ref provider] is a_Invoice_Desc. [Ref provider])
    AND (a_Invoices. [Invoice No.] is a_Invoice_Desc. [Invoice No.)]
    WHERE (((a_Invoices. [<>ACK GL account]) »--- »)) ;

    for the quarter, I tried with select to_char (to_date ("PRVBTOT", "dd/mm/yy '"), 'Q') as quarterdate of "a_Invoices" - it worked, but how to combine all the

    Hello

    882431 wrote:
    Thanks for the input... I have another doubt based on the date

    I have a date stored in a field of type varchar, n'm copy in the date field

    For example: ' 18/4/2011 0:0:0.0' varchar field is, I tried with "' 2011/4/18 as yyyy/mm/dd ', I can add hh: mm: for the moment (I wasn't looking this), but there is one.0, can someone please tell me how shud convert it..." Sorry if asking a basic question, I already searched but to no avail.

    DATEs do not include fractions of a second. If you don't mind losing fractions of a second, you can simply remove them before pass the string to TO_DATE, like this

    TO_DATE ( REGEXP_REPLACE ( varchar2_column
                    , '\.[0-9]*$'
                    )
         , 'YYYY/MM/DD HH24:MI:SS'
         )
    

    REGEXP_REPLACE will remove the decimal point and any numbers after him. If the string does not contain a decimial, it is correct: REGEXP_REPLACE returns the immutable string in this case.

    If the fraction of a second is important, use a TIMESTAMP instead of a DATE column (and use the TO_TIMESTAMP instead of TO_DATE function).

  • Error that using TO_CHAR (TRUNC (SYSDATE), 'DAY') FROM DUAL

    Hello everyone.

    I have a pl/sql procedure that contains TO_CHAR (TRUNC (SYSDATE), 'DAY') FROM DUAL to capture the DAY in a variable. Now when I access this procedure of someother application (Workflow), I get the error ORA-01841: (full) year must be understood between-4713 and 9999 and not be 0.

    If I do not use TO_CHAR (TRUNC (SYSDATE), 'DAY') and hardcode the value, it throws no error.

    Any ideas on this error?

    Is this something to do with the NLS_DATE?

    Thank you

    Kind regards

    Pavan K

    >
    ...

    IF (TRIM (SAT_DAY) = 'SATURDAY')
    THEN
    L_DAYS: = L_DAYS + 2;
    ELSIF (TRIM (SAT_DAY) = "SUNDAY")
    THEN
    L_DAYS: = L_DAYS + 1;
    ON THE OTHER
    L_DAYS: = 1; - FND_PROFILE. VALUE ('DSD_PAF_TIMEOUT'); -Getting the value of timeouit in days
    END IF;
    L_DAYS: = L_DAYS * 24 * 60;

    First, you add two days if it's a Sunday.
    Then you multiply by 24 * 60.
    Are you sure that this logic is ok?

    I guess you just use bad values for the L_days parameter.

    The difference between last Friday and today, without doubt is:

    last Friday, the variable L_days has been VERY VERY VERY big, for example 20000000 = (x + 2) * 24 * 60)

    Today, it's only 1 * 24 * 60 = 1440.

    Published by: W. Sven on September 21, 2009 18:01

    Looking at the error message...

    ORA-01841: (full) year must be between-4713 and 9999

    My current guess is that you have created a date that goes beyond the year 9999.

    Published by: W. Sven on September 21, 2009 18:05

  • Peux I installed iOS 10 from my iPad to my iPhone6 or my PowerbookPro? Or 10 doesn't automatically do that? Doubt it!

    Peux I installed iOS 10 from my iPad to my iPhone6 or my PowerbookPro?

    Or 10 doesn't automatically do that?

    Doubt it!

    If you're wondering how to install iOS 10, go to settings on your iPhone. Then click on general, then software update. Wait to check out the update, and then click Download and install at the bottom of the iOS 10 pop up.

  • How to find the serial number of the processor in the MacBook pro s serial number? I have a dead MacBook that was given for service to a third party. I doubt that they have replaced the original parts. Help, please. Thank you

    How to find the serial number of the processor in the MacBook pro s serial number? I have a dead MacBook that was given for service to a third party. I doubt that they have replaced the original parts. Help, please. Thank you

    As far as I KNOW, the serial number of the MacBook does not have the serial number of the processor.

  • I have a doubt... the two Firefox syn account and firefox support account are the same or not

    I have a doubt... Firefox and firefox syn account for both are the same or not change support

    Hello shivarajnaidu, not for the moment these two accounts are completely separate, although it is planned to link the two of them on behalf of persona in the foreseeable future: https://login.persona.org/about

  • I got a message saying my iCloud id has expired. The text has a link and asks me to enter bank details. Is this doubtful

    Ive got a text saying my iCloud ID has expired and its got a link and asks me to enter bank details. Is it doubtful?

    Do not reply or reply!  Sounds like a phishing attempt.

    http://www.Apple.com/legal/more-resources/phishing/

    Identify the fraudulent 'phishing' - Apple Support e-mail

  • I'm ready to buy a Apple Watch in this week... so my doubt

    I'm ready to buy a Apple Watch in this week... so my doubt and fear is if Apple Watch 2 starting soon can exchange with my product? Anyone hv any idea or much knowledge about the launch d & all please help me with your valuable answers.... plz

    < published by host >

    Apple has made no announcement about Apple Watch 2. Speculation is forbidden on the forum, so without an official announcement, nobody here could say. Given that nothing has been said, I doubt that you would benefit from an exchange of your product. They do not trade for new devices in any case for the watch. iPhones and iPads can be returned for recycling and a store credit, but that's it.

  • Doubts on my new book

    Hi all:

    I bought a new book a few days ago. I am really satisfied with this wonderful machine. After using it for a few days, I have two doubts:

    (1) the fan in my booklet is most of the time. Is this normal?
    (2) what are the specifications of memory? I want to upgrade the RAM in my machine, but I have no reference manuals for do I have to use the memory modules.

    Thank you very much

    In case it helps to... My experience with my U100 is the fan is certainly * not * "almost all the time." For example, I went about 40 minutes before to check emails, news, etc., using the power of the battery and the default 'normal' power setting, and the fan is not switched on once. (Room temperature is 23 degrees c).

    If I use it outside in the Sun very as the case becomes hot to the touch, the fan tends to come regularly.

    If it runs on my desk from the power outlet (using the parameter 'high power' by default) and I do the work of the processor hard as when you make a disk backup or editing photos, then yes the fan are quite light. But it's just like most laptops.

    If she does everything what * and * the sun shines directly on it as well, then the fan comes on saying maybe 50% or more of the time. (A silver case would have reduced the effect of solar heating - but look very smart matte black ;-).)

    How does this compare with your experience?

    To the subject of RAM, yours came with 512 MB like mine? (I guess this would be the module PA3312U - 2M 51, as described on this site - 512 MB memory PC2700 DDR SODIMM (333 MHz)).

    Before I bought the machine the provider told me that he has that one slot RAM and that in order to upgrade the memory, I would need to take the existing 512 MB and replace it with a 1 GB module. But I have not confirmed which and there is no mention of a module of 1 GB on this site. The 512 MB so far seems sufficient, but I would be interested to know if you are able to increase the RAM on your U100.

    Kind regards
    David Tong.

    PS. It occurs to me that if you feel the need to increase the RAM, then maybe you do work pretty hard machine, in this case you expect the fan to be busy.

  • Table - doubt

    Hello. I have a job to do which is: we have to create a table of random numbers () and the user gives a number he chooses. We need to create a new table with all table at random numbers that are larger than the number of the user.

    I did this: http://img291.imageshack.us/my.php?image=helpaipeop3.jpg

    My question is: How can I create a new table with all the numbers that are larger than the number?

    In the future, please attach images directly to your message instead of placing them on ImageShack so people can access it directly.

    To answer your question: you're not understanding dataflow. Since there is that no dependencies in the data between the 2 loops then the 2 loops will be different at the same time. However, the background loop runs with empty bays are filled until the top loop ends. Your incorrect use of local variables is a mistake and the number without a doubt one of the reasons why we see programmes does not properly. Please make sure that sets are filled before you try to use them. That said, is there no need 2 loops first. The comparison just there where you generate the random number. Use a shift register to accumulate a table. If the random number is larger than the control, and then add it to the table. If this isn't the case, pass through. Use a box structure. Like this:

    To learn more about LabVIEW, it is recommended that you go through the tutorials and look over the material in tutorials the NI Developer Zone Learning Center , which provides links to other materials and other. You can also take a course online for free.

  • Doubts on Xperia Z3 double Downgrade, enter recovery

    Hi, I upgraded my dual Z3 using PC companian and I do worse than worse battery life that lasts hardly 8 hours with an average of 2 hours on the screen using only a SIM... Don't recommend me to cut my mobile data live wallpaper etc... I don't need two days back up like advertising, I just need at least a day...

    And my question is can it downgrade to KitKat without rooting my phone? When I used the Sony Emma software to connect my phone with PC, it showed that your phone is locked and you need to unlock your phone to activate the features...

    And other doubt is how to reset recovery mode my phone? I tried with a large number of key combinations and all are allowed in normal startup upward...

    And tell me any othere ways to regain my battery upward without decommissioning if there is place (even though I don't think so)

    I appreciate your valuable suggestions... Thank you

    Yes, you can downgrade without rooting see here for a guide on how to create your own firmware and how manually Flash your phone, but you may need to find the firmware from another country if it is available or search XDA

    Said EMMA instructions Sony what - for use with compatible phone and only for phones that have a Bootloader unlocked

    Finally there is no magic button combo to go into recovery mode as Xperia devices do not have unless you have rooted and installed a custom recovery

Maybe you are looking for

  • What is ECCN for the browser Firefox (v10 &amp; v17) and Manager of Remote XUL?

    Lockheed Martin wants to distribute the United States to its employees (non-US) international one copy of Firefox and Remote XUL Manager. To do this, we require the ECCN classification for these two products. Can you please provide.

  • Satellite A50 - recovery disk is not working

    Hello I'm trying to do a clean install on my laptop, but the recovery disk is not working.The files transferred to the laptop, but once done, I get an error message that says: "the system is not fully installed. Please run Setup again." Does anyone h

  • TURegOpt program location not found skipping autocheck

    I use Xp3, these days, every time I turn on my PC, it appears this message "turegopt program location not found skipping autocheck", how can I do?My email: * e-mail address is removed from the privacy * if you can help me, thank you very much.

  • At the start, I now get the message: AGMailAgent.exe

    At the start, I now get the message: Windows cannot find 'AGMailAgent.exe '. Make sure you typed the name correctly and then try again. To search for files, click the Start button, and then click search. » As I haven't typed anything at startup, I'm

  • M127fw HP: Hp software Mf127fw online

    Installation printer HP M127fw on MAC OS. No CD player. Where the MFP HP Laserjet Pro software online?