How to convert date format in number?

I have a sql like this:
select to_date('MAR','Mon', 'NLS_DATE_LANGUAGE=American') m from dual
I want to display "3" instead of showing the Mar...
I tried to use to_char(date,'MM'), but the result will return '03'.
I would like to have the output exactly equal to 3.

Thanks Bros.

920575 wrote:
I have a sql like this:

select to_date('MAR','Mon', 'NLS_DATE_LANGUAGE=American') m from dual

I want to display "3" instead of showing the Mar...
I tried to use to_char(date,'MM'), but the result will return '03'.
I would like to have the output exactly equal to 3.

3 (without the single quotes) is a NUMBER. It is exactly equal to the NUMBER 03.
"3" is a string. It isn't equalt to the string '03'.
Do you want a NUMBER or a string?

If you want the chain of characters-1 '3', use 'FMMM"instead of"MM ".

select  TO_CHAR ( to_date ('MAR', 'Mon', 'NLS_DATE_LANGUAGE=American')
                , 'FMMM'
                )   AS m
from    dual

To_char sometimes add padding (sometimes spaces, sometimes ' 0) for elements a constant width. For example, a few months need 2 characters for the "MM" format, then, TO_CHAR default, buffers left with '0' to do monthly 2 characters, whether or not they have need of 2 characters. With the help of "FM" (case sensitive) IN the format string change whether or not this kind of padding will be added.

You could also use LTRIM to remove leaders ' 0 in this case, but why delete them when it is easier, is not to generate them in the first place?

Tags: Database

Similar Questions

  • How to convert Date format in the Apex?

    Hi all

    I created an element of Apex Date Picker as "yyyy-mm-dd", now when they select this date picker, that must be converted in "day, month, DD, YYYY".
    I trired like that but it does not work, can anyone help me to find things to do.

    Under article, we have free will.

    Default value: to_char (to_date (: P1_ENG_DATE, 'dd-mm-yyyy'), ' day, month DD, YYYY ")
    Deafult value as type - PL/Sql.

    Thanks,
    David...

    Hello

    You can set the date format level of application, then you don't need to specify the format each time.

    for this go to "Modify the Application Properties"-> globalization

    Here you can specify the format of date of application.

    Thank you
    Tauceef

  • convert date format period

    Hi all

    Here are my existing query which I run another tool to extract data from oracle-

    Select * from transactionTbl

    WHERE

    DATE > = TO_DATE (' $(vAppStartDate)', "DD/MM/YYYY")

    AND DATE < = TO_DATE (' $(vAppEndDate)', "DD/MM/YYYY")

    variables-

    -vAppStartDate = 06/01/2014

    -vAppEndDate = 30/06/2015

    Rather than use the Date column in the WHERE condition, I want to use PeriodID of column existing in the same table, to make the query faster.

    The period column is in below format.

    PeriodID format-> 201294 //means 2012Q 4. So 9 means Q

    Since I'm on variables, the values are always to the date format, so my requirement is first change variable date from periods of format.

    I wrote the pseudo-code, because I of course know how to convert date format periodID. Q also means in the periodID 9.

    Select * from transactionTbl

    WHERE

    PeriodID > = period_function (TO_DATE (July 1, 14 ',' DD/MM/YYYY '), 'YYYYxx')

    AND PeriodID > = period_function (TO_DATE (July 1, 15 ',' DD/MM/YYYY '), 'YYYYxx')

    Please help me with the query.

    Thank you!

    Calling a user-defined function is likely to slow down your query.

    What's the problem with just using regular date formatting strings for example

    SQL > select to_char (to_date('15/09/2014','DD/MM/YYYY'), 'YYYY "9" Q') of double;
    TO_CHA
    ------
    201493

    1 selected line.

  • Convert date format

    How to convert date format

    23/03/2010 to March 23, 10

    I'm passing date front end which is the format 23/03/2010 and happens in a query, and I do not get the results in the table it's March 23, 10

    How to apply the conversion of this attribute

    First to view the description of the column attribute_date1 table

    If its data varchar2, date, or timstamp type

    If attribute_date1 is the data type date

    Select * from mst_pindetails where attribute_date1 = to_date (March 23, 10 ',' DD-MON-RR')

    If attribute_date1 is varchar2

    Select * from mst_pindetails where to_date (attribute_date1, "DD-MON-RR') = to_date (March 23, 10 ',' DD-MON-RR')

  • convert date format dd.mm.yyyy jj.mm.AA

    Hi all

    My need is to convert date format dd.mm.yyyy jj.mm.AA. All years are 1999 or less. My first assumption is to use the combination of substr with concatination of '19', but maybe someone can suggest another decision.
    select '18.03.97' as dt from dual

    You can do this:

    SQL> select to_char(to_date('18.03.97','dd.mm.rrrr'),'dd.mm.rrrr') Result from dual;
    
    RESULT
    ----------
    18.03.1997
    
  • How to convert to format Date in milliseconds

    Hi all

    I am getting the output of a variable in milliseconds format, how can I convert it in date format

    For ex: I get variable input like 1366664691000 and I need to convert it to April 22, 2013 23:04:51 CEST (or SOA form). is there any function for this in XSL or XPath?

    Thank you

    Hello

    My XSLT works now after making a few changes

    and included namespace xmlns:fn = "http://www.w3.org/2005/xpath-functions.

    Now, I'm successfully number of days. My use case is to delete the files of the bases on the number of days. (i.e. changed the time - current date).

    Once again thank you @ vladidos

  • How to convert date to number

    Hai

    How to convert the date as a number.

    Thanks and greetings

    srikkanth. M

    Look at these messages
    Please help me in converting Format of Lilian date
    converstion to date
    and try something like that.

    SELECT sysdate,sysdate-to_date('15-10-1582','DD-MM-YYYY') lilian_dt FROM dual;
    
  • How to automatically convert date format

    My question is that the definition fix date format for form hole, assume I get the data in the date column
    the date should be automatically format how in this example, type 01012010 only when I press ENTER after that show both 01/01/2010. but do you remember the shape of the hole because I don't want to enable it for each column.

    I also tried on after change and after query, but it does not work.

    Dear Sir

    I already mentioned in my coding read carefully, you must create a form level, think how is possible, you define triggers above level of the item and work for the shape of the hole.

    Thank you

  • How to convert date in month, YYYY

    Hi all

    I have a date column that is in the format ex: (12/06/2013) the user wants it to appear like June 2013. Can you help me how I can achieve this?

    Thank you

    Ravi

    GO to the column-> properties-> data format select custom data format

    write the format MMMM, YYYY

    Kind regards

    Rémy Agarwal

  • How to convert Date months in the database that points to the EBS, DWH not.

    Hi friends,

    We intend to create reports in OBIEE and the Source is EBS. This means that we do not want depends on Datawarehouse and Informatica and OBIApps. Simply create us some reports and that they refer to the EBS database.

    End of test, we took an HR report and it contains under columns:

    Months (Sun)
    Revenue by Division (Fact)
    Average cost per numbers of workforce (Fact)

    In my little survey, we found that the income column is of EBS: GL_BALANCES. And we have configured the base of W_Day_D table in DAC has no column months in EBS (not sure).

    Come to my problem, how can I call the month column in my data base stressed EBS. How to convert the Date months in my database.

    I can deceive me, but someone please look into this... How can I create columns for this exact report of OBI in EBS database instead of DwH.

    Thanks in advance...

    Raghu Jen7782

    Just confused here.

    Hang on, if I get it, you want to create report based on columns of EBS directly then using rt BI applications?

    There is then no question of using the W_DAY_D table then.

    Follow

    As long as you have Date column, you can use DB functions to convert them into months (just use the string SUBSTR to extract the month and the year).
    Create your own query instead of using the tables of BI APPS and try to bring a hybrid product.

    Sorry I'm wrong in the understanding of your needs, if I had properly then do the steps above.

    Mark correct or useful if this can help,

    Kind regards
    Rayan Vieira

  • How to convert data from XY graph for type ' signal in "for measurement functions

    Hi all, I have a driver file that generates the screenshot XY graph.  I want to measure the period, using the measurement functions in the LabVIEW palette.  Can someone tell me how to convert this type of signal "in".  The X (time) and Y (power) are all there, but it causes an error when I son together?

    Please see my attached code.

    Thank you

    Its ok people, I found a solution.  See attached FYI.

  • convert Date format MMM DD YYYY to DD/MMMM yyyy

    Hello

    I'm in the studio EN 11.1.2.1... We have an obligation to display the date in the format yyyy MMMM dd is lets say 10 January 2015 should display as 10 January 2015

    Members exist in Essbase outline: creation Date

    The Member is used in the grid and the value of the cell is displayed in a block of text as < < GetCell("Grid1",1,A,1) > >

    I don't see the preference option to set as DD/MMMM YYYY format that is available for System Date function < < Date (jj/aaaa "MMMM") > >


    I also tried with true measures typed and activate the date format, but it does not work in EN report and it seems that the preferred default setting takes precedence.

    Untitled.png

    any suggestion will help...

    Thank you

    KP

    It resolved, post the answer might help someone in the future...

    good to know that the file-> preferably in the workspace can be changed... DD MMMM YYYY gives me the date to January 10, 2015 according to my expectations.

    I changed the Date in the file format-> preference for the financial report

  • How to convert Date floating number

    Hi everyone, I want to make a time measure of the hall sensor and use that value to set a frequency, and also to use as the value of process in a PID controller. the problem is that I get a result of dynamic data and I would like to have this in a floating number, is that possible? or another way is also good... hereby a jpeg to make it more clear.

    I also have more problems with that, when I change the throttle (0-100%) is does nothing and my time loop also doesn't stop more. This is just a small part of the full program, it's may be heavy for my computer? (core 1, 6 GHz, 1, 5gig of ram)

    hope it's a bit clearer what I mean

    Thanks in advance!

    PS: I know that the fracture by one is useless because you can directly measure the frequency, which has already changed.

    the program is intended to push a PMSM motor

    You can change the type of dynamic data for the meter using the function of Double-precision float in the digital - Conversion scheme.  For your other question, you are not showing your loop together so I can't help you there.  What stops the loop?

  • How to recover data formatting... Encrypted external hard drive

    I have a 500 GB portable external hard drive, which I had encrypted using Bit Locker in Windows 7.

    I accidentally formatted the disk.
    How can I recover the data.
    I tried several software data recovery as (recover my files & Stellar Phoenix Windows Data Recovery - professional) etc., but they don't find all the data from the disk was encrypted.
    I would be grateful for any help I could get.
    thanx

    Hello

    Unfortunately, we will not be able to recover the data because the drive has been formatted. Done with the help of Bitlocker encryption has further complicated the issue. However, try to contact a team of data recovery known who do it for a minimal amount according to the amount of data to restore.

  • Convert date format timestamp format

    Hello, I have the following code in * impl.java in the doDML method. I'm getting "invalid column type" at run time, but when I click on insert. I think that the problem is because I do not convert the timestamp format format date correctly. Any help please?

    CallableStatement cs1 = null;

    try {}

    / * Some code here * /.

    d = new java.sql.Date java.sql.Date (this.getRbcDtFrom () .getTime ());

    CS1. SetDate (2, d);

    java.sql.Date d1 = new java.sql.Date (this.getRbcDtTo () .getTime ());

    CS1. SetDate (3, d1);

    CS1. SetString(4,"RBCS");

    CS1. SetString (5, this.getRbcCode ());

    CS1.setInt (6, getRbcCounter ());

    CS1. ExecuteUpdate();

    Boolean ValeurRet = cs1.getBoolean (1);

    If (retvalue)

    {

    super.doDML (operation, e);

    }

    else {}

    System.out.println ("no Commit!");

    }

    } catch (SQLException f) {}

    throw new Aexception.getLocalizedMessage (f);

    }

    You did not created wrapper fucntion.

    Take a look at:

    Troubleshooting

    Use the same principle for the registered function...

Maybe you are looking for

  • specific App password has not created

    I am trying to create a specific app password.  I go to security on appleid.apple.com, I click on edit, I click on generate the password, I see a password, I copy and paste into the app, I need to and it does not work.  I try to select done first the

  • Damaged laptop hard drives can be recovered?

    Hello I hope you can answer my question, as I've had a little trouble with my TOSHIBA Satellite Pro The strap of my laptop broke so that on my shoulder, and the bag bag fell to the floor. In 1 of the card slots PC is a wireless LAN adapter. (Bad luck

  • Reset &amp; drive usb Iomega GDHDU2 information

    I have an Iomega GDHDU2 USB drive apparently with a drive hard Samsung HD 103SI in that I am connected to a Bell Expressvu receiver sat TV like a VCR digital and used for awhile, but then disconnected after a few questions but now try to use it again

  • icloudhelper. XPC is an element of a set of keys locked. What specific item does?

    Hello friends! Wake up, a dialog box appears. "com.apple.icloudhelper.xpc wants to use the bunch of frobnutz. This "frobnutz" keychain is locked (intentionally). I would like to move whatever it is that icloudhelper wants in the (unlocked in the morn

  • How do Photon calendar app stop mailing me I have no events

    Basically, that's all. I don't want you receive email (to my gmail account) I have no events on a particular date. How to stop the calendar of Photon app to do this?