problems by analyzing a date format string...

Hi all, I'm having a hard time to convert a date into a string.

I was using to_char but after much research, I thought that it would be better to use convert so I do:

SELECT CONVERT (VARCHAR (8), 'November 19, 2012', 112) twice;

Where the specifications for 112 is YYYYMMDD but I get the error "ORA-00936: lack of expression ', guess is cause Oracle do not know how to read the string to be converted.

How can I convert a YYYYMMDD string format string of the form dd mmm yyy (as described above)?

Thanks in advance,

It seems that your search will lead you to a SQL Server thread. SQL Server uses arbitrary numbers to represent date formats. Oracle does not - the number 112 is irrelevant for Oracle.

In Oracle, you convert a date to a string using the function TO_CHAR

SELECT to_char( date '2012-11-19', 'YYYYMMDD' )
  FROM dual

Of course, this assumes that you start with a date (like I do with my date literal). If you start with a string representing a date and you want to convert it to a string that represents the same date in a different format, you will need to use a TO_DATE and a TO_CHAR to convert the original string to a date and date on another string

SELECT to_char( to_date( '19 Nov 2012', 'DD Mon YYYY' ), 'YYYYMMDD' )
  FROM dual

Justin

Tags: Database

Similar Questions

  • Date format string SQL Conveting XML

    Hi all
    I have a question where a date that comes as input to a string format must be inserted into a database is Timestamp. Can someone help me on this...

    the date format which I recive is '2008-08-01' where "yyyy-MM-DD" I have to convert it in the format "YYYY-MM-ddTHH" Help with this convert Timestamp would be a great help.

    Hi Sissi,
    Please use the format-dateTime function in xslt and to generate the time portion of the date, use the '00' instead of hh, mm, and ss. This function automatically converts an XML datetime SQL string.

    The function will look like this - dateTime(YYYY-MM-DDT00:00:00) format.

    Concerning
    AYUSH

  • slight problem with display of date format

    I have this query that produces a correct result, but not in the date format I need. Currently, it is the 'DD-MON-RR' display and I need it to appear in the format "MM/DD/YYYY". Can someone help me?

    Thank you
    Deanna


    SELECT TO_DATE(:P21_BEGIN_DATE,'MM/DD/YYYY') + (: P21_DAYS_OLD) FROM DUAL;

    Never use implicit date conversions:

    SELECT TO_CHAR(TO_DATE(:P21_BEGIN_DATE,'MM/DD/YYYY')+:P21_DAYS_OLD,'MM/DD/YYYY') FROM DUAL;
    

    SY.

  • 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.

  • Daylight Saving Format Date/Time String vs get time in seconds

    Hi all

    I have developed a real-time application using a cRIO 9074 which has two loops. The first gathers data and records the time using the module of ' string of Format Date/time ' with the following time sting: '%d/%m/%Y % H: %m ". The output is a sting with mouth/day/year hour: minute.

    The second loop Gets the cRIO time using the module "get Date/Time in Seconds ' and the output of timestamp is sent by a shared variable for an application that is running on a local computer.

    The problem started Sunday last with DST. With the help of MAX I am able to see that the time of cRIO is bad (1 hour less) and that him "automatically adjust clock for daylight saving time" is not checked and gray, so I am not able to change it.

    The time of the first loop by using the "Date and time Format string' returns the time elapsed between the cRIO (1 hour late), however the time of the second loop is OK. I have manually corrected time using MAX, so now the first loop is correct, and the second is now over an hour.

    Any ideas?

    Dear RavensFan, thank you very much for your answer.

    However, this was not the problem. Apparently the result with or without the element of DST is the same. I solved the problem, for now, by changing a parameter not on the function "get Date/Time in Seconds" but on the time stamp indicator.

    By right clicing the indicator and go to the display Format and the advanced editing mode, I have changed the Format string to a universal time container of this: %< %="" h:="" %m="">< t="" %="" ^="">< %="" h:="" %m=""><>

    Apparently the time from the 'get time in seconds' is still an hour longer, but now it is correctly displayed.

  • Problem with the conversion of getDate() to Date format?

    Hi guys,.

    I need to convert the date selected for DateField string format (for example: yyyy-mm-dd).

    I put the date format DateField as "mm-dd-yyyy '.»

    I tried to get the date of this DateField and tried to convert the format 'yyyy-mm-dd ".

    When I tried, I had a bad outing.

    For example, when I selected 12 months he returned as "00" the following coding.

    SimpleDateFormat dtFormat = new SimpleDateFormat("yyyy-mm-dd");
    Date dtToConvert = new Date(mydatefield.getDate());
    strRequired = dtFormat.formatLocal(dtToConvert); 
    

    Can someone explain what that is the bug with this code or any other way to get the output as my requirement?

    Thanks in advance,

    Stéphane

    Oops, sorry, code should have been...

    DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
    long dateLong = field.getDate();
    Date date = new Date(dateLong);
    String dateString =df.format(date);
    
  • date format picture ends before converting all of the input string

    In the following query, I get the error: ORA-01830: date format picture ends before converting all of the input string

    Select sum (e.gl_fig) in the rm_gl e where e.as_on_dt < = trunc (to_date('31-Nov-2011'), 'Q')-1

    Hello

    Moreover, how many days are there in November? It IS 30 or 31?

    Please change from 31-Nov-2011 to November 30, 2011, then it works.

    select sum(e.gl_fig) from rm_gl e where e.as_on_dt <= trunc(to_date('30-Nov-2011', 'DD-MON-YYYY'),'Q')- 1
    
  • Another problem with date formatting

    I want the date to appear at the Mmm - DD - but I get the date format full ODBC

    my query:
    < cfquery name = "monthlyChart" datasource = "2onboard" >
    SELECT distance, time, walkDate
    OF bockWalk
    WHERE the month (walkDate) = #month (Now ()) # AND year (walkDate) = #year (Now ()) #.
    < / cfquery >

    My cfchart:
    < cfchart format = "swf".
    style="/XML/dailyDistanceGraphs.xml".
    chartheight = '175 '.
    chartwidth = '575 '.
    ShowLegend = 'no '.
    showborder = 'yes '.
    show3d = 'no '.
    ForegroundColor = "000000".
    scaleFrom = '0 '.
    yaxistitle = "Mileage" >
    < cfchartseries type = 'bar '.
    Query = "monthlyChart."
    ValueColumn = 'distance '.
    PostesColonne = "walkDate".
    SeriesColor = "ff0000" >
    < / cfchartseries >
    < / cfchart >

    I tried formatting with an XML file
    Part of the XML file
    < xAxis >
    < isMultiline labelStyle = "false" orientation = "vertical" / >
    < style labelFormat = "Longdate" pattern = "Mmm - DD" / >
    < / xAxis >

    Quote:
    Posted by: jkgiven
    MikerRoo...
    Your solution stacks all of my entries in a column instead of one for each date, why/how to fix?
    Why the line in my work of xml?
    Can you explain or direct me to a source, the functioning of your lines? -J' I really need to learn XML, but it does not seem quite logical for me.

    Your entries are all in a single column because that is:
    (1) you have not set the pattern parseFormat matches what was returned by the database
    or
    (2) the granularity of the chart is set for monthly data and the data cover enough time. Change the dateTimeStyle to:

    did not work because (1) you need to set the mode to datetime axis
    and (2) the graphics engine is very stupid and need to be told exactly how to analyze the values returned in the query. It is the purpose of the tag.

    Finally, you need not learn the XML as such.
    The XML styles are covered, a little, in the docs from

    There is a practical tool, webcharts designer that you can use to generate the xml styles in:
    c:\CFusionMX7\charting\webcharts.bat

    The Webcharts user guide covers the styles available in more details. You can download that here:
    http://www.WebCharts3D.com/website/WebCharts50/download/index.jsp

  • Getting ORA-01861: literal does not match format string whith 2 passes DATE

    Not exactly a complete Newbie, but not an expert either but it left me speechless...

    I have two DATE columns in two different tables.
    In a select statement I compare these two in the where clause.

    ... and
    Table1. Column1 = table2.column1

    I then get

    ORA-01861: literal does not match the format string (and toad has highlighted the second column)

    I made a selection on the two tables to have a look at the values and found that, the values in a table (Toad), has this format: YYYYMMDD but in the other select table produces a column of values in the format YYYY-MM-DD

    I've made a desc on the two paintings and confirmed that the two are DATE columns...

    I've never seen different date formats in the same database... Thinking about it now (I'm home and can not verify) the two tables could be in different schemas... Different schemas can display different date formats?

    In any case, I tried to_date ([column] on the two (in the where clause) and got that a nonnumeric value has been found where a numeric value has been planned (this time for the first column).)

    So I guess I ask how come two different date formats and how to find the nonnumeric value in table 1 which contains lines of 5.8 million

    Any tips/ideas/tips?

    Please check back when you get back to work... I can almost guarantee you that one (if there is not both) of these columns is NOT a data type DATE (or timestamp).

    Or if they are, you are actually handled in a view or query to convert to this type of data.

  • Formatting string to date in BPEL

    Y at - it a way to format a string to date in BPEL value.

    I would date a string and I need to push this date value in Oracle data to a field that is of data type Date. I don't see no function in BPEL, which is allowing me to do.

    For example my entry of BPEL is ' 01/01/2010' and I need to convert this string in the variable of type date and assign one of the fields in one of the tables in the Oracle database.

    I use xp20:format - dateTime function, but it is also to give me the time that I am not able to introduce into the database of the field is specified as the date.

    I'm doing this conversion in the allocation and transformation process.

    Thank you
    Arun-

    Published by: user626948 on August 28, 2008 22:40

    I guess you are trying to insert in the database through the database adapter. The DB adapter always represents a database as XML dateTime date. The default format to create a dateTime is YYYY-MM-DD' you hh. To create a dateTime valid object to be inserted into your database with the given substring you would end up with an expression such as:

    XP20:format-DateTime(Concat(Substring('01/01/2010',7,4),'-',SUBSTRING('01/01/2010',1,2),'-',SUBSTRING('01/01/2010',4,2),'T00:00:00'))

    assuming that 1 January 2010 is in MM/DD/YYYY format. In the expression builder you will probably replace the 1 January 2010 "with a reference to a variable that contains the date value.

    Kind regards
    André Jochems

  • BUG: Date/Time Format string with %D in the format string crashes LabVIEW

    Do %D in the format string 'Format string DateTime' blocks LabVIEW 2009 SP1, as shown in this code snippet.  Should I use instead of %D %d but an incorrect format string should not crash LabVIEW.

    Fixed in 2010.

  • Date Format problem

    Hi all

    We spend date format '2015-05-26' of soapui for check-in, so it's inclusion in the database successfully.

    "But for the check-in validation Post filter service we copy the same date format from custom metadata to each other using Update Sql. we receive below IE error ' [' ORA-01843: not one month valid '.]

    Under sql queries work well for me. I've updated one of the rows in the table to approve revisions using sql developer, and it worked fine.

    UPDATE SET dcreatedate = TO_TIMESTAMP('15-MAY-2013 11:00:00:00','DD-MON-YYYY HH24:MI:SS:FF') WHERE did = 89 revisions;

    OR

    Setting a DAY of revision SET dcreatedate = systimestamp WHERE did = 89;

    You use java filter to update the query? Resource query you use?

  • How to analyze the data of 10 bytes encoded in the HH306 of Omegatte data logger/thermometer?

    I am trying to write a simple code for a HH306 of OMEGAETTE thermometer/travailleursduweb.com data recorder.

    That is the problem. I communicate with the device via RS - 232, using Labview 8.5.1 and windows xp. I ask her for "all the coded data", which is actually the only option. He returns 10 bytes of encoded data, the manual describes the meaning of each byte and I understand that. The problem is that I can't analyze the information for use in labview, for example: I want to extract the temperature and simply display it.

    on request, I get: 10bytes (read as a string from the serial port read buffer): display HEX: 02 00 A8 48 FF EF B6 49 B6 03 is perfect, and what I expect.     Display codes: \02\00\A8\B6H\FF\EF\B6I\03 The Normal display is a series of special characters, I don't understand, especially since I don't think they are ascii characters that must match returned hexadecimal numbers!   For the life of me, I can't understand how to extract the information (what are the 48 6 hexadecimal display) of what is returned. All string manipulation functions seem to work only on what is given in Normal view. (The 4th and 5th byte of the data are the codes of the BCD for temperature: for example the temperature was 64.8 degrees farenheight when I took this reading).

    Can someone help me to analyze the data returned by this device?

    Ok... I think that I thought about it. I found this: http://digital.ni.com/public.nsf/websearch/77C8F61D36F5A23086256634005ACB38?OpenDocument.

    I guess the normal display garbled is corresponding to each hexadecimal ascii characters. I'm just not used to seeing characters beyond the decimal number 127 ascii or hex 7F.

    So, basically, to analyze the 10 bytes of data:

    (1) break the string read from the serial port in the 10 ascii characters (using String subset vi)

    (2) son of each output string in the left input of 10 separate Type vi Cast.

    (3) wire a constant U8 in each terminal 'type' VI Type Cast.

    cables of 4) the chain of each Cast of Type vi output to the input of a number hexadecimal string vi.

    (5) concatenate or use as you wish as hexadecimal numbers (now in string format) which cause.

    See you soon.

  • How can I configure the cell data format

    How can I configure data format of cell numbers: for example, I want to capture 123456.78 and need to be 12A3456.78?

    I tried to put #A # #. # format option, but it didn't work a few time and it became A123456.78.

    I also tried on excel and it worked very well, but I like the numbers better. is there a solution to this problem?

    Thank you

    HEY Chi - Lun,

    I don't think that this is possible as many number format. You should be able to insert A in a text string using a formula, but this would happen in a second cell, not that the number has been entered.

    "Assuming all the"numbers require the same inserted letter after the second number, this should do the work."number" entered in column A; the formula in column B. In the table below, your value as an example is A6.

    = Left (A, 2) & "A" & RIGHT (A, LEN (A) - 2)

    Kind regards

    Barry

  • Analysis of the variable format string

    Question, I have a string I need to analyze in separate string variables. Analysis errors out string if the string is parsed cannot fill every type defined in the string format. The problem I have is that the string length varies depending on multiple strings separated by spaces up to 13 different string types sometimes and sometimes only 6. Is there another way to scan the string in different channels with the command of token or something and not use this as the format varies?

    I've attached an example of what I'm trying to do.

    Thank you.

    Here you go...

Maybe you are looking for