Formatting an XML string that has a date

Hi All - new to this forum!
Not familiar with XML operations and seeking some advise. I have a field that contains XML text that has a date within that I want to extract and format appropriately for some reports.
Getting to the date portion of the field is not pretty (original code below) and could desire some work itself, but the real problem lies in formatting the date once extracted; sometimes the date text is in the format of "Month DD YYYY" and other times "DD Month YYYY" so the below code fails if the latter is found.
SELECT TO_DATE(RTRIM(SUBSTR(email_variables, INSTR(email_variables,'CHECKIN_DATE')+22,18),']]></CHECKIN_DATE><CHECKOUT_DATE>]'),'Month DD YYYY') CHECKIN_DATE,COUNT(*)
FROM t_ecomm_relations_queue
WHERE code_corr_ecat = 'PREA'
AND status IN ('A', 'R')
AND TO_DATE(RTRIM(SUBSTR(email_variables, INSTR(email_variables,'CHECKIN_DATE')+22,18),']]></CHECKIN_DATE><CHECKOUT_DATE>]'), 'Month DD YYYY') < TRUNC(SYSDATE) + 7
AND TO_DATE(RTRIM(SUBSTR(email_variables, INSTR(email_variables,'CHECKIN_DATE')+22,18),']]></CHECKIN_DATE><CHECKOUT_DATE>]'), 'Month DD YYYY') >= TRUNC(SYSDATE)
GROUP BY TO_DATE(RTRIM(SUBSTR(email_variables, INSTR(email_variables,'CHECKIN_DATE')+22,18),']]></CHECKIN_DATE><CHECKOUT_DATE>]'),'Month DD YYYY');
Any ideas for more efficient code or options for formatting is appreciated.
Thank you!

The best thing to do with a date you want to report on, is to not store it corrupted inside XML.
Multiple reasons why are discussed here.
If you are stuck with the ugly inefficient design, then you are probably stuck with ugly inefficient code as a result.

Similar Messages

  • A class to format an XML string into indented xml code

    I am looking for a class or a piece of code to format an XML string into indented xml code
    for example: an XML string as follows
    <servlet><servlet-name>Login</servlet-name>servlet-class>ucs.merch.client.system.LoginServlet</servlet-class></servlet><servlet-mapping><servlet-name>Login</servlet-name>
    to format into :
    <servlet>
    <servlet-name>Login</servlet-name>
    <servlet-class>ucs.merch.client.system.LoginServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Login</servlet-name>
    <url-pattern>/Login</url-pattern>
    </servlet-mapping>
    e-mail : [email protected]

    Xerces has a class called OutputFormat
    If you have your XML document in memory, you can format it using the method setIndenting(true) on the OutputFormat class. The following is an example:
    assuming xmlDoc is our document and fileName is the name of the file we wish to write to:
    OutputFormat format = new OutputFormat(xmlDoc);
    // setup output file name
    PrintWriter printwriter = new PrintWriter(new FileWriter(fileName, false));
    // construct an XMLSerializer for writing the document
    XMLSerializer serializer = new XMLSerializer( printwriter, format );
    // Ensure output is indented correctly...
    format.setIndenting(true);
    // set serializer as a DOM Serializer
    serializer.asDOMSerializer();
    // serialize the document
    serializer.serialize(xmlDoc);
    hope this helps!
    Rob.

  • Dynamically Setting a Variable from a Connection String that has been set by a Config File

    Hi Guys
    I'm setting up a Master / Slave (Parent / Child) dtsx environment but I'm unable to work out how to dynamically set a variable in the Master dtsx from a connection string that has had its value set by a config file. I'm sure it's possible.
    Below is the what I'm hoping to achieve. I've set up everything apart from the highlighted section.
    Any ideas?

    First, what version of SQL Server are you using?
    You could switch the problem around.  You could set the value of a variable from the config file, then it is easy to use that variable as the connection string source for your connection manager.  At the same time you can use a parent variable
    configuration to map that variable to variables in your child package.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • [svn:bz-trunk] 20693: Add a web.xml. crx that has no MessageBroker and RDSServlet.

    Revision: 20693
    Revision: 20693
    Author:   [email protected]
    Date:     2011-03-08 13:09:18 -0800 (Tue, 08 Mar 2011)
    Log Message:
    Add a web.xml.crx that has no MessageBroker and RDSServlet.  Remove reference of webtier in HttpServiceTest.java.  Not sure which tests are using this class and hopefully we can get rid of it since webtier.jar is about to be gone.  Watch out for any new failtures that might be related.
    Modified Paths:
        blazeds/trunk/qa/apps/qa-regress/WEB-INF/src/dev/httpservice/HttpServiceTest.java
        blazeds/trunk/qa/apps/qa-regress/build.xml
    Added Paths:
        blazeds/trunk/qa/resources/webtier/qa/web.xml.crx

    I am modifying the correct httpd.conf file on the server, it just doesn't seem to work. - If I put the rewrite rules in the <Directory /> the rewrite works but it adds /Library/WebServer/Documents to the URL.
    I also tried putting the rewrite rules in <IfModule mod_rewrite.c> but that did not work either.
    mod_rewrite is enabled and running on the server.
    I will post the rewrite rules again in the code brackets. Sorry for the long post. - If some one can try them out on their Leopard Server to see if they can get them to work, it would be much appreciated. Again, these work on my Leopard Client but I can't get them to work on Server.
    -- The httpd.conf file posted above is just the default conf file found in /private/etc/apache2/
    <code>
    RewriteEngine On
    Options +FollowSymLinks
    RewriteRule ^(.+)/$ http://%{HTTP_HOST}$1 [R=301, L]
    RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.php(.*)\ HTTP
    RewriteRule (.+)\.php(.*)$ $1$2 [R, L]]
    RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.asp(.*)\ HTTP
    RewriteRule (.+)\.asp(.*)$ $1$2 [R, L]]
    RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.aspx(.*)\ HTTP
    RewriteRule (.+)\.aspx(.*)$ $1$2 [R, L]]
    RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.htm.(.)\ HTTP
    RewriteRule (.+)\.htm.(.)$ $1$2 [R, L]]
    RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.cfm(.*)\ HTTP
    RewriteRule (.+)\.cfm(.*)$ $1$2 [R, L]]
    RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.bak(.*)\ HTTP
    RewriteRule (.+)\.bak(.*)$ $1$2 [R, L]]
    RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\.inc(.*)\ HTTP
    RewriteRule (.+)\.inc(.*)$ $1$2 [R, L]]
    RewriteCond %{THE_REQUEST} ^GET\ ([^\?]+)\..(.)\ HTTP
    RewriteRule (.+)\..(.)$ $1$2 [R, L]]
    <code>

  • Closing XML node that has been queried closes (crashes?) LabVIEW

    Can someone confirm this observation with closing an XML node that has been searched with the XPath expression of "/" only?  This can be reproduced with the shipped XML example "Query XML Document for a Single Node.vi".  Change the XPath expression to just the forward slash and notice that LabVIEW will close (or crash?) when the VI is executed.
    Thanks

    It doesn't crash until the origional node is closed.  In the example pic it is not unitl it reaches the last "close" does it crash.  I also gets a valid node from the search.  Also, the /* doesn't crash it but the Result XML is not the same.
    I am attempting to teach myself some stuff on XML and XPath expressions and according to WC3:
    / selects the document root (which is always the parent of the document element)
    Anyway, I don't ever plan on using / as a standalone search element but wasn't expecting the crash...
    P.S. & FYI my overall purpose is to parse out data from XML files generated by TestStand.  I need to mine some data...
    Attachments:
    Query XML Document.png ‏40 KB

  • Where does FireFox get the default value of a preference from. What is the format of the file that has the default value?

    Where does FireFox get the default value of a preference from. What is the format of the file that has the default value?. I need the actual default value for a particualr preference.
    About:config does show some default values but I need the source from which about:config picks up the default value.
    Any help in this direction is greatly appreciated.
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)

    The prefs that aren't hidden if they are the default are stored in two JavaScript text files in the Firefox program folder
    You can open them via these links in a Firefox tab:
    <code>resource:///defaults/pref/firefox.js
    resource:///greprefs/all.js
    </code>
    ([/forum/1/702598])

  • BEx Broadcaster broadcasting the MS Excel file of size 1kb and that has no data

    Dear Friends
    As one of the BEx query is taking more time to execute and the session is going timed out before it displays the output, I have created a broadcaster setting for the same. I have created the broadcaster setting with the Distribution Type as "Broadcast Email" Output format as "XML (MS Excel)", but when I receive the broadcasted Excel which is only 1 kb and which doesn't have any data. Please throw some light on this if you have encountered a similar problem before n resolved it.
    Thanks & Regards
    Ranjan Jinka

    Hi,
    What the problem ? Broadcasting or memory issue need to be decided first.
    For broadcasting test, run the report in foreground for bare minimum records, and see output is coming. Then broadcast it and see if it works.
    For session out, you need to think on how to reduced the size of output file. I also suggest check the DB setting of your BW system. Ask your DB administrator about the issue you are facing related to session time out.
    Thank-You.
    Regards,
    VB

  • I want the simple calendar shown in the zeen manual that has the date and time on it. Where is it?

    I followed the recommendation on another post to link my google account for the calendar.  So now I have a full month calendar but I want the one that's in the zeen user manual that has only the date and time.  Can anyone tell me where I find that exact one?  I've looked through the apps download section and found all sorts of things but nothing that's a calendar.  I think it was there before the update was downloaded.  At which time I had to link my google account to get anything.  Also, has anyone else tried to get anything android on the zeen and get the message that you don't have an android compatible product?  Don't know what that means.  I'm trying to get myself into the 21st century but I'm not all tech or gadget savvy.

    Bomberos wrote:
    Personnaly i hate that calendar, i would like to have back my calendar, the old one, same one that it's on my ipad version 1. Is it possible?
    No.
    Suggestions here -> http://www.apple.com/feedback/

  • In BI Answers, show X axis series/unit in bar chart that has null data.

    Hi,
    I am showing data for each day of the week as a bar chart. Days of the week are the X axis. Sunday
    sometimes has no data but I still want to show it.
    Has anyone got any ideas?
    Many thanks,
    Graham

    This will most likely need to be a modification in your RPD if not your data source. It can be accomplished in the RPD though.

  • How do I fix email that has a date of 12/31/00 and no content

    how do I fix an email that base a date of 12/31/00 wand no content

    Quit the mail app completely and reboot the iPad. Go to the home screen first by tapping the home button. Double tap the home button and the recents tray will appear with all of your recent apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Tap the home button or anywhere above the task bar.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • Turn a string that shows hex data in normal format, into a string that shows the same data in hex format

    I have a string of arbitrary length - say, 1AB1C0 - in normal format. I would like to have a function which takes that string in, and outputs the same exact characters, but in hex format. So the input will read 1AB1C0 in normal string format, and the output will read 1AB1C0 in hex string format.
    I am doing this because I have found the end device works better if I send the bytes as a hex string vs. as an array of U8. Furthermore, I manipulate a lot of byte streams in my program, and I find the string parsing tools less cumbersome to use vs. the byte array parsing tools - however, they only work on the strings as they appear in normal mode. So I have reasons in different parts of my program to have the string in normal vs. hex formats; but I cannot figure out any remotely elegant way to cast from one to the other.
    Solved!
    Go to Solution.

    CraigRem wrote:
    So the input will read 1AB1C0 in normal string format, and the output will read 1AB1C0 in hex string format.
    Well, you need to scan the hex formatted string two bytes at a time to an U8 numeric and then cast it back to a string. There are many ways to do that, here are two possibilities. (Mkae sure to use the correct representations as labeled).
    (I still don't quite understand your reasoning why you need this).
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    NormalToHex1.png ‏12 KB

  • How can I read an XML string that's not from an XML file?

    I've got a script I'm trying to setup that communicates over a socket to retrieve different directions from a custom built Java program.  The Java program listens to requests from the Adobe scripting engine (in my case it's a Photoshop script) on a socket and immediately responds with the next set of directions.  These directions are currently in XML format.  The issue I'm having is that I can't parse the XML data since it's entered into a new XML object from a string rather than being read from a file.  Even without the socket code, you can see the issue by doing the following:
    var xml = new XML("<test><data>hey!</data></test>");
    alert(xml.test.data);
    alert(xml);
    The first alert "should" return "hey!" (without quotes, of course), but it doesn't, while the second alert returns what you would expect it to:
    <test>
        <data>hey!</data>
    </test>
    It works fine if read from an XML file, but from a string, like shown above, it just presents an empty alert box when attempting to access "xml.test.data".  Any ideas on how to fix this issue?  Can it be fixed?  Has it been fixed in newer versions (I'm currently using CS4)?
    Thanks in advance for any help!

    Duh... found my error... I was attempting to access the data by referencing the created "root" element.  Since <test> is the very first element tag, it's setup as the root element, which you don't need to reference.  Changing the alert to alert(xml.data); fixed it.
    Now I just feel dumb, lol...

  • How to read xml file that has changing element names?

    Idon't know much about xml, nor reading it with java, but I have this problem with reading xml file. The file something like this:
    <configuration>
       <DEV001>
          <serial>001</serial>
          <id>number 1</id>
       </DEV001>
       <DEV002>
          <serial>002</serial>
          <id>number 2</id>
       </DEV002>
    </configuration>I have imported the org.w3c.dom.* api, that I use for parsing. I don't know is this a generic or a parser specific issue, but how can I get all the nodes starting with "DEV" into a NodeList?
    If you know a solution for this with another parser, please share it. I have no reason to use that specific parser, I just found a sample using that.
    kari-matti

    Well, NodeList is an interface, so you cannot construct one and put the "good" elements into it. But, you might be able to cast the NodeList with all of the children of the root into an IIOMetadaNode (which is the class that implements the NodeList interface. That class has a removeChild() method that might be able to remove the text nodes and any that don't start with DEV.
    But, if you remove nodes, and still want to do things with the full DOM Document, be very careful and run tests. It may remove those nodes from the full Document.
    If, on the other hand, the printingData( Nodelist nl) method could be modified so it takes an ArrayList or some other collection, it is very simple.
    Just create an ArrayList, and when you find an element starting with DEV, add it to the ArrayList. When you are done, process that list and you are finished.
    Dave Patterson

  • How do you format a numbers file that has been sent from excel?

    I have a report card that I have sent from a PC using excel to my air mac numbers program.  It sent it in four parts.  How do I format this?

    Denise,
    Select the cells, click the format icon to open the format panel, choose the cell tab and pick the format that you want to apply.
    Jerry

  • Is trim() useful for splitting up a string that has a delimiter?

    Hi all
    below is an example of my data
    Col 1
    abc_ijk
    a_xyz
    pq_b
    I need to split up abc_ijk into 'abc' and 'ikj' and store them into another table. Can i use trim? I know that i can specify the number of characters to split it up, but my number of characters for each row is different. how can i tell trim to remove everything after(including '_') so that i can get abc, as well as remove everything before(including '_') so that i can get ijk?

    And in 10g you could use regular expressions ... (scnr)
    WITH t AS (SELECT 'abc_ijk' col1
                 FROM dual
                UNION
               SELECT 'a_xyz'
                 FROM dual
                UNION
               SELECT 'pq_b'
                 FROM dual
    SELECT col1,
           REGEXP_SUBSTR(col1, '[a-z]+', 1, 1) fld1,
           REGEXP_SUBSTR(col1, '[a-z]+', 2, 1) fld2
      FROM t;C.

Maybe you are looking for

  • Java.lang.UnsatisfiedLinkError + servlets

    Hi, While accessing JNI methods thru Servlets, am getting java.lang.UnsatisfiedLinkError. Am I missing on some configuration/deployement steps. Please let me know your thoughts. N

  • Wave 2 P.O app

    Hello All,      I wanted to customize Purchase Order Application(wave 2 App).I made  necessary changes in index.html,configuration.js(url) and component.js(modulePath) and tried running locally using Tomcat but it was not working..then I tried testin

  • Forum search not working

    When i try to search the forums for help on a search form, I get the following message: The web site you are accessing has experienced an unexpected error. Please contact the website administrator. The following information is meant for the website d

  • Is it possible to a coloured background in sap script Form.

    Hi all, Is it possible to a coloured background in sap script Form. Point is guranted

  • HP PSC1350 and Snow Leopard

    I just wanted to share my experience with Snow Leopard. I've heard there are problems with Snow Leopard and some HP Printers. I depend on my printer for school, so I played it safe and installed Snow Leopard on an external USB drive and played around