Format Date question as VARCHAR

Using Oracle 10g:
I have a varchar field that is holding a date like:
2010-08-28 14:40:21
I'm trying to format the date so I can check if it's greater than the sysdate. I'm trying to do:
TO_CHAR(end_date, 'YYYYMMDD' ) > to_char(sysdate,'YYYYMMDD');
I'm getting an error:
ORA-01722: invalid number
01722. 00000 - "invalid number"
Which makes sense but I'm just not sure how to properly format the end_date to the YYYYMMDD format.

Hi,
user9179751 wrote:
Using Oracle 10g:
I have a varchar field that is holding a date like:
2010-08-28 14:40:21
I'm trying to format the date so I can check if it's greater than the sysdate. I'm trying to do:
TO_CHAR(end_date, 'YYYYMMDD' ) > to_char(sysdate,'YYYYMMDD');
I'm getting an error:
ORA-01722: invalid number
01722. 00000 - "invalid number"
Which makes sense but I'm just not sure how to properly format the end_date to the YYYYMMDD format.Is end_date the VARCHAR2 column?
TO_CHAR, as the name suggests, converts a DATE TO a <b>CHAR</b>acter string. If you already have a character string, then there's no need for TO_CHAR.
You might want to call TO_DATE, such as
WHERE   TO_DATE ( end_date
                , 'YYYY-MM-DD HH24:MI:SS'
                )  > SYSDATEbut it's more efficient and less error prone to say
WHERE   end_date > TO_CHAR (SYSDATE, 'YYYY-MM-DD HH24:MI:SS')Why is it more efficient? The optimizer considers SYSDATE to be a constant, even if the query takes a significant amount of time. Therefore, it will only convert SYSDATE into a string once, even if you have a million rows in the table. If you did it the first way, you would have to call TO_DATE a million times, once for each row. Also, because your column, end_date, is alone on one side of the > operator, the optimizer can use an index on that column.
Why is it less error prone? If you have even one row where end_date is malformed, you'll get an error if you call TO_DATE. By not even trying to convert end_date, you don't risk any errors.
This only works because the format of end_date is suitable for sorting. If the format were, say, 'DD-Mon-YYYY', you would have to convert it to a DATE.
It would be better if end_date were a DATE column. It's never a good idea to use a VARCHAR2 column to store points in time.

Similar Messages

  • How to print formated data/report on client's printer (Web Application)

    Hi All
    I want to print some formatted data/report ( it might be 1000 pages) on user's printer.
    Application is web based
    Technology used are Java - jsp - servlets
    i want functionality like...
    when user click on print button/link, data is fetched from server and all pages (it is formated data so i want alignment on page while printing) should be printed one after another.
    Also printer selection dialog should displayed one time when user click on print button/link.
    Questions:
    1. How i will transfer all data to client (web browser) from the server ??
    2. And how i can print that data on user's printer ??
    There is requirement (or limitation) that I can not use applet for this purpose.
    And also it is not fix that we must use java tech., we can use any othere tech. but condition is that it must support multiple platform (in short platform indipendant)
    There is solution like ...
    I can use window.print() function of DOM/JavaScript,
    but it prints only one page which is displayed on browser.
    I don't want to display any page. and want to print all pages.
    if any one done or have idea then let me know.
    Thanks in Adv.
    Shailesh Koradiya

    thanks linxpda for reply,
    we can use ActiveX component for windows platform for printing purpose, same way we can use platform specific component for printing... (for linux, unix, sun solaris etc...)
    if it is possible then let me inform.
    Thanks,
    Shailesh Koradiya

  • Error When Refresh Formatted Data inside Excel Analyzer

    I have build a Excel template and load up this to the BI Publisher Server. When I call this template after the log in works fine. When I refresh the data normal it works also fine, but when I try to refresh formatted Data I get the error "Error: This report does not support HTML as an output format." I will not use html output inside Excel, I will use the original Excel template with refreshed data.

    Hi Tim,
    The Refresh Formatted Data works on MS Excel 2003.
    May need to check if its really supported on MS Office 2002.
    Btw another question, is it possible to create an excel template without using Excel Analyzer?
    Also when I used the generated excel file of Excel Analyzer as template, when the report is generated the data sheet sometimes is not filled with correct data or sometimes there is no data at all, even if the parameters used is the same as the one used in generating the original excel file using Excel Analyzer. This happens most of the time for reports with Concatenated Queries or SQL Queries using "CURSOR" to group a set of data. Note that on initial generation of excel file using Excel Analyzer, correct set of data is displayed. It is only when it is used as template and viewed/exported in Excel format that data is not properly loaded.
    Please advise.
    Thanks!
    Uniz

  • Function Modules for Format Date, Month Name and Quarter value.

    Hi All,
    1. I am getting the date field from the Flatfile, so i need to format the date to YYYYMMDD. Is there any Function module for that in BW.
    2. Based on the above Formated Date i have to find out the Name of the Month like JANUARY, FEBUARY etc.
    3. Based on the same above Formated Date i need to find out the Quarter like 1, 2 etc.
    Could you please let me know if any function modules are there for the above questions in BW not in ABAP, why i mention is some Function modules are there in ABAP but not in BW.
    Thanks in advance.
    Regards,
    srinivas

    Hi ,
    1.If your input date format is MMDDYYYY then Use SDATE as conversion routine in trans strucutre to convert into YYYYMMDD.
    2.By passing year as input parameter for the following FM you would get all the months with text.Using READ statement in routine you can get month name
    MONTH_NAMES_GET
    3.For Quarters you can use the following FM:
    TSTR_PERIODS_QUARTERS
    hope it helps...
    regards,
    Raju

  • Z10 Voice Control speaks in US-format date for Uk date

    Issue: UK format date 02/08/13 is "said" by Voice Control as "2nd August" - the date is in the calendar correctly as 8th Feb.
    Steps to repeat the issue: "Schedule new appointment" using the Voice Control and add an appointment today (8th Feb 2013) - correctly added to the Calendar but the voice confirmation says "2nd August".

    Hey dpjf,
    Welcome to the BlackBerry® Support Community Forums.
    To better assist you I have a couple questions:
    When you go to Settings> Voice control> Is the Language set to English UK?
    Go into Settings> Language and Input> What is the Display Language and Region set to?
    Thanks.
    -HB
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • Java message bundle format date - Help

    Hi, I use that MessageSource.java:
    String description = getMessageSource().getMessage(msgCode, msgParams, ApplicationLocales.DEFAULT_LOCALE);
    where msgParams is Object[]{myDate}
    and msgCode is what I have in my .properties file...
    for example:
    customer.create.message=New customer has been created, date: {0}
    myDate can have different formats (with date and without it): like 2005-10-10 14:00
    If it doesn't have hours, the {0} should manage it and the description shouldn't have the nonsense 0:00 time (it happens, if date is without hours)
    I know that i should write something to {0} but thats the question. Maybe someone has better knowlegdne of this technique?

    I've gathered info from about 5 different links. Do u
    know some good tutorial covering formatting data in
    details?Formatting dates is quite well-documented in the API docs (links from reply 1)
    You can check DecimalFormat for numeric data, or ChoiceFormat for formatting a range of numbers.
    There is also a tutorial from Sun about formatting.
    Hope it helps.

  • Format Date for time.

    i have a doubt as to how to store the date along with time from my front-end Forms Developer Suite 9i application.
    I am trying to give this kind of statement from SQL-plus:-
    update login_master set last_accessed=to_Char(sysdate,'dd-mon-yy HH:mi:ss')
         where login_ID = :GLOBAL.LOGIN_ID
    but, there is a message which comes like this:-
    ORA-01830 date format picture ends before converting string.
    Also, i want to compare this time stored against time a little later, say after 1 or 2 hrs to get number of minutes.
    How can i do this? I hope, my question is clear. Please help in solving the doubt.
    regards.

    This topic is a duplicate of this one:
    <p>Format Date for time
    <p>Please reply on the other thread.

  • Import csv through SSIS package - format date column

    Hello -
    I need to import a csv file to SQL server using SSIS.  The date column in excel is, for example, 7/8/2014, but it imports as 41828 in SQL Server.  How can I convert this?
    Any help will be greatly appreciated!

    Hi,
    According to your descrition, date column convert to string data type column when import data from a csv file to SQL Server table. While you want the column still stores as date data type in SQL Server table.
    In order to achieve this goal, there are several methods:
    Add a Derived Column Transformation before the OLE DB Destination. Then add a derived column  to replace the date column with the expression like bewlow to convert the column to date data type:
    (DT_DBDATE)column_name
    Add a Data Conversion Transformation before the OLE DB Destination.Then convert the date column to date[DT_DATE] data type. Use the new column as the destination column.
    In the OLE DB Destination Editor, we can change the data type from varchar(50) to date when create a table as the destination.
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to print formatted data / report on user's printer in Web Application

    Hi All
    I want to print some formatted data/report ( it might be 1000 pages) on user's printer.
    application is web based and tech. used are Java - jsp - servlets
    now prob. is ...
    how i will transfer all data to client (web browser) from the server and how i can print that data on user's printer ...??
    there is requirement that I can not use applet for this purpose.
    if any one done or have idea then let me know.
    thanks
    Shailesh Koradiya

    Hi
    Its simple, first of all break ur data in terms of pages. Write the logic in one JSP.
    suppose i have jsp PrintReport.jsp , for page 1 url will PrintReport.jsp?page=0 ... so on
    get the page parameter in JSP
    String page="";
    if(request.getParameter("page")!=null)
    page=request.getParameter("page");
    get the rowcount from the Result and assume records per page is 100
    if u have 1000 rows then 10 pages u have to serve
    StartRowNumber=page*recordsPerPage
    EndRowNumber=StartRowNumber+recordsPerPage
    Execute a SQL query , select * from table where rownum between
    StartRowNumber and EndRowNumber
    Provide google like pageNumbers in ur HTML page
    ie 1 2 3 4 5 6 ..10
    Regarding printing , Create HTML button called 'print' and add Javascript ' window.print()' on clicking it.
    Hope it would solve ur problem
    Cheers
    Rajendra Bandi

  • Error in outputting xml formatted data

    Hello,
    I'm trying to output xml formatted data using apex.
    At about 70% into the formatted output I get this in the browser:
      <descript>punct= & > < /,() &</descript>
      </row>
    - <row The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Only one top level element is allowed in an XML document. Error processing resource 'http://apex.oracle.com/pls/otn/f?p=158...
    <script language="JavaScript1.1" type="text/javascript">
    -^
    m">>
    <DIVI have a 600 row table (dml below) with identical string in each row of the descript column. (I put in some special characters just to push it through the escape function for html. It is displaying the text correctly.)
    The page has one report region (plsql below).
    The page template is stripped down.
    My local results are identical to the otn hosted workspace.
    I did dump the table in xml format and displayed the dump file in browser without a problem, so I'm missing something in the code.
    Thank you.
    Albert
    On OTN webspace, go to http://apex.oracle.com/pls/otn/f?p=15866:1:1291425545573680200:::::
    plsql
    declare
    xdescript varchar2(4000);
        begin
        -- xml preface is in the page template
        -- htp.p('<?xml version="1.0"?>');
        htp.p('<rowset>');
        begin
            for item in
            (select descript,cid from receipts order by cid)
            loop
            htp.p ('<row>');
            xdescript := htf.escape_sc(item.descript);
            htp.p('<cid>' || item.cid || '</cid>');
            htp.p('<descript>'|| xdescript || '</descript>');
            htp.p('</row>');
            end loop;
        end;
        htp.p ('</rowset>');
    end;
    dml
    CREATE TABLE  "RECEIPTS"
       (     "CID" NUMBER,
         "AMOUNT" NUMBER NOT NULL ENABLE,
         "CLEARED" DATE,
         "DESCRIPT" VARCHAR2(80),
         "DATEENTERED" DATE DEFAULT SYSTIMESTAMP,
         "CHECKNBR" NUMBER,
         "CLEARSEQ" NUMBER DEFAULT 0,
          CONSTRAINT "RECEIPTS_PK" PRIMARY KEY ("CID") ENABLE
    CREATE SEQUENCE   "RECEIPTS_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999
    INCREMENT BY 1 START WITH 4319 CACHE 20 NOORDER  NOCYCLE
    CREATE OR REPLACE TRIGGER  "BI_RECEIPTS"
      BEFORE INSERT ON "RECEIPTS"
      FOR EACH ROW
    BEGIN
        SELECT "RECEIPTS_SEQ".NEXTVAL INTO :NEW.CID FROM DUAL;
    END;
    ALTER TRIGGER  "BI_RECEIPTS" ENABLE
    /

    May be it helps you. I use SQL/XML and APEX Application Process to generate XML succesfully
    Here is the result:
    http://htmldb.oracle.com/pls/otn/f?p=9774:101:0:APPLICATION_PROCESS=RSSNEWEVENTS
    and here is the Process Text source:
    declare
    a clob;
    begin
    owa_util.mime_header( ccontent_type => 'text/xml', bclose_header => TRUE, ccharset => 'utf-8');
    htp.prn('<?xml version="1.0" encoding="UTF-8"?>');
    select
    XMLTYPE.getStringVal(
    XMLElement("rss",
    XMLAttributes('2.0' as version),
    XMLElement("channel",
    XMLConcat(
    XMLElement("title",'iActiveLife - novinky'),
    XMLElement("link",'http://www.iactivelife.cz/'),
    XMLElement("description",'iActiveLife - Zajímavý život snadn&#283;ji'),
    XMLElement("language",'cs'),
    XMLElement("pubdate",''),
    XMLAgg(
    XMLElement("item",
    XMLConcat(
    XMLElement("title",event_name),
    XMLElement("link",'http://htmldb.oracle.com/pls/otn/f?p=' || v('APP_ID') || ':37:' || v('SESSION') || '::NO::P37_EVENT_ID:' || event_id),
    XMLElement("description",'')
    ) into a
    from (
    select event_id,event_name,issue_date, last_update_order
    from (
    select events.event_id, events.event_name, events.issue_date, rank () over (order by events.issue_date desc) as last_update_order
    from events
    where exists ( select * from opportunities where events.event_id=opportunities.event_id and opportunities.user_id is not null)
    order by events.issue_date desc)
    where last_update_order<=10
    htp.prn(a);
    end;

  • How to use format-date with the report parameter

    Hi all,
    How to use the format-date function with this tag,
    <?param@begin:P_FROM_DATE?><?$P_FROM_DATE?>
    this form date is coming from report parameter and is coming like this 2012/11/01 00:00:00.
    So now i need this in DD-MON-YYYY fromat.I tried like this <?param@begin:P_FROM_DATE?><?$format-date:P_FROM_DATE;'DD-MON-YYYY'?>
    but its giving error. Can any one pls tell how to convert it to customized date format.
    thanks & Regards
    Srikkanth.M

    Issue solved.
    Ref this link
    XML date Format

  • How to use many format data into a template?

    How to design a template but it can interface from many format data? 

    This is the one from 2010 but should still work.
    http://www.bfcnetworks.com/blogs/alexpearce/pull-sharepoint-2010-document-properties-into-word-quick-parts/
     You basically create a new document in the library (must have the columns you want into the word document), then you use the Quick
    Parts to insert the data where needed. Then you save this document as your template. Then anytime someone creates a document in the library when you open the document it will read from the columns of the item.
    I used a workflow and had the users actually update a SharePoint list, then that in turn creates a new document in the document library and populate the columns from the list form. Then You can send that document link to folks to download / print or whatever.
    Is that what you are talking about?

  • Formatting dates in a table in webdynpro java for mutliple entries.

    Hi all,
    I have a requirement to format date values in a table for multiple entries to dd/MM/yyyy format in webdynpro java for mutiple line items in that table.
    Please help me out with the technique for the same.
    Thanks and Regards,
    Soumyadeep.

    Hi,
    here is the code for changing the formatting the date.
    Date currentDate = new Date ();
                DateFormat df =  DateFormat.getDateInstance(DateFormat.SHORT);
                String today = df.format(currentDate);
                SimpleDateFormat sdfInput = new SimpleDateFormat("dd/mm/yyyy");
                SimpleDateFormat sdfOutput = new SimpleDateFormat ("mm/dd/yyyy");
    try {
                      String dateft = sdfOutput.format((Date) sdfInput.parse(df.format(currentDate)));
                } catch (ParseException e) {

  • Format Date function not working correctly

    Hi,
    I am using the following code to display a system date:
    <?xdofx:sysdate('DD-Month-YYYY')?>
    However the date always appears as:
    18-March -2011 (with space after 'March')
    rather than
    18-March-2011 (no space after the month)
    Can anyone tell me how to get the date to display without the space after the month?
    Thanks

    Some options:
    http://winrichman.blogspot.com/2008/08/xslt-extended-functions.html (right side screen shot)
    BI Publisher:formating date using xdofx
    Modify the output from current_date

  • Format Data doesn't work?

    Hi
    I want to see numbers in Discoverer formatted as set in Administrator, which is
    999G999G990D99.
    The Format Data dialog box tells me that 'Default' formats numbers as they have been set up by your Discoverer manager, using the format 9999999999.
    Only, I am my own Discoverer manager and I set up 999G999G990D99.
    I can find that setting in EUL5_EXPRESSIONS.IT_FORMAT_MASK and I can see changes done with Administrator.
    Why don't they show up in Discoverer?
    Hints appreciated
    Franziska

    Instead of selecting 'Default' go to more Number
    formats and seelct the one you want.In which dialog do you find these 'more number formats'?
    That will become the new default format.I need different formats for different columns. So one default won't do.
    Hope this helps!Afraid not.
    Thanks
    Franziska

Maybe you are looking for

  • File too large for volume format?

    I'm trying to copy a 4.6GB .m4v file from my hard disk to an 8GB USB flash drive. When I drag the movie in the finder, I get a dialogue telling me the file "is too large for the volume's format". That's a new one for me. If the flash drive has 8GB av

  • Unit costing for materials assigned to activity - for material cost plannin

    The requirement is that material cost to the company will vary depending upon the project/customer. Eg.: Material cost = basic material cost + a % for P&F + 2 % for Clearance + a % for excise + 2 % for insurance + a % for Customs It can be a % or a l

  • PE10's odd behaviour in not asking for discs 2 and 3.

    My computer complies with system requirements and I have a brand new 'unopened' PE10. The box has three discs. I installed disc1 and the serial number and I was not told to install the other two discs. The installation surprisingly closed down. There

  • MIDI Drums

    Hi, The MIDI drum loops I select sound OK when listening to them, however, when I drag them up to create a new track, the sound is not the same and is often pitched? Anyone got any suggestions?

  • DskPercent not returned for ZFS filesystems?

    Hello. I'm trying to monitor the space usage of some ZFS filesystems on a Solaris 10 10/08 (137137-09) Sparc system with SNMP. I'm using the Systems Management Agent (SMA) agent. To monitor the stuff, I added the following to /etc/sma/snmp/snmpd.conf