Comparing date format having hh:mm:ss:pm

Hi
In table the records are stored in this format
6/15/2010 1:20:12 PM (mm/dd/yyyy hh:mm:ss PM/AM)
I need to get the records having the date greater than 6/1/2008 00:00:00 AM
How can i get that
I tried the following trunc (dt)>= to_date('06/01/2008','mm/dd/yyyy' )
Please correct me in this query

smile wrote:
Hi
In table the records are stored in this format
6/15/2010 1:20:12 PM (mm/dd/yyyy hh:mm:ss PM/AM)
As VT pointed out, if you are storing that as a character string (varchar2), then that is very poor design.
If you are storing it as a DATE, then it is not stored in the format you suggest. It is stored in oracle's internal format for DATE. NLS_DATE_FORMAT controls how that internal format is presented in a result set.
I need to get the records having the date greater than 6/1/2008 00:00:00 AM
How can i get that
I tried the following trunc (dt)>= to_date('06/01/2008','mm/dd/yyyy' )
Please correct me in this queryThe answer depends on the data type in which you are storing the supposed date/time.

Similar Messages

  • I am having trouble getting a numbers spreadsheet to hold different formats in the same column.  A column with a date formatted heading will not convert to $ for the cells below.   Any suggestions would help.

    I am having trouble getting a numbers spreadsheet to hold different formats in the same column.  A column with a date formatted heading will not convert to $ for the cells below.   Any suggestions would help.

    Hi Wayne,
    Thank you for this response.  I have tried this but when I start enterring $ amounts some, such as $6.00, go in OK others such as $4.00 appear as a date ie 4 Oct 12.  
    Kind regards
    Paul

  • How can I permanently change the date format from the American format to the UK's without having to constantly change it manually every time I start a new spreadsheet?

    This is my first mac so I'm still getting my bearings with it. I've only used Windows programmes before. I can't understand why it's so hard to change the date format of the cells in Numbers to keep it showing the UK format. The system preferences of the mac show that it's in the correct region and has the correct date but this doesn't seem to transfer into the Numbers program. I was very impressed with the mac until I discovered this. If anyone knows how I can get the date to stay in the correct format without having to go through the process of altering it in the cell inspector everytime then I would be very grateful.

    Numbers & most apps, especially those from Apple, use the date format you have set in System Preferences > Language & Text > Region. You can then choose UK from the Region drop-down list. Mine says Custom because I've defined things further as in the second screenshot.

  • Variable substitution in Unit Testing validation - Date format?

    Using SQL Developer unit testing, I am having difficulty comparing Date datatype in a validation.
    I use a Dynamic Value Query to set the parameters of an insertion procedure under test.
    select * from (select doc_nbr as p_mstr_doc_nbr, doc_nbr as p_assoc_doc_nbr, sysdate as p_date_added from documents sample(0.01) order by dbms_random.random)  where rownum <= 1;So P_DATE_ADDED is a DATE datatype.
    I wish to validate that the insertion was correct. So I run a Process Validation returning one or more rows.
    SELECT * FROM X100_ASSOC
      WHERE MSTR_DOC_NBR = '{P_MSTR_DOC_NBR}'
        AND ASSOC_DOC_NBR = '{P_ASSOC_DOC_NBR}'
        AND to_char(DATE_ADDED,'dd-MON-yy HH24:MI:SS')  = {P_DATE_ADDED};I understand that the {P_DATE_ADDED} is substituting in a string. From Help page :
    "What is actually substituted is the string representation of the parameter value. For example:
    If P1 is a parameter of type NUMBER and has the value 2.1, the string {P1} will be replaced by the string 2.1.
    If P1 is a parameter of type VARCHAR2 and has the value ABC, the string '{P1}' will be replaced by the string 'ABC'. (Note the single-quotation marks around {P1} in this example.)"
    I need to know the format that the date is cast into as a string. Then I can do the comparision on the where clause.
    Any answers? or details of where is more in depth documentation?
    Thank you,
    Bill

    I agree as a general rule. However in this case, it appears that the variable substitution routine is returning the default format. So to compare my expected data to the returned data I choose to use the default format. If the variable substitution routine specified an explicit format, I would use that. In my original question, I asked if anyone knew the format.
    Regards,
    Bill

  • Problem in loading 0calday infoobject date format through Flatfile in cube

    Hi All,
    I am facing problem  in loading the 0calday infoobject  data through flat file( format - test.csv) in infocube..
    Suppose consider we are having two flat files(test1.csv,test2.csv).
    1.First file(test1.csv) has a proper date format (ie YYYYMMDD), while loading it is succesfully .
    2.Second file(test2.csv) has improper date format(ie DDMMYYYY), loading fails because of this format..
    Is it possible to write the Routine(Start Routine) in the Infopackage (External data-Tab) in such a way the if the flat file(test1.csv) is proper date format load calday data without any conversion, if the file is test2.csv convert the date field format from (DDMMYYYY) to (YYYYMMDD) and finally laod data in cube.
    With regards,
    Hari.
    +91 9323839017

    Hello Dinesh,Anil
    There is no distinguishing field between the two flat file loads.
    We are using only one infoobject(ie 0calday) for two loads.
    We are using two external source system(one system generate file as YYYYMMDD date format,and another system generate date formate as DDMMYYY, here two file names are unique.
    Here my requirement is i have to compare two file names using start routine of the package (tab:External data) .
    if(test1.csv)
    load as it is 0calday data (since it is in proper format YYYYMMDD)
    else if(test2.csv)
    then convert from DDMMYYYY to YYYYMMDD and load data to 0calday infoobject in cube.
    Is it possible to compare two files names using start routine.
    with regards,
    Hari

  • How to compare date which is greatest date

    iam new to sql
    how to compare date which date is greatest date with example
    can i use to_char to compare date
    SELECT eno, ename, GREATEST (TBLE.MAX1, TBLE.MAX2) recent_date "
                   FROM (SELECT TBLA.eno, TBLA.ename, "
                   MAX (TO_CHAR (TBL.date1, 'MM/DD/YYYY HH24:MI') "
                   ) MAX1, "
                   MAX (TO_CHAR (TBL.date2, 'MM/DD/YYYY HH24:MI') "
                   ) MAX2 "
                   FROM dual TBL, dual2 TBLA
    in above query if any one of the date having null value then recent_date is showing 'null'
    and also it showing wrong value
    example
    date1='08-22-2009' and date2='01-23-2010' then it showing wrong recent_datel ike='08-22-2009'
    as according my knowledge it is comparing with month it sholud not be like this wat i have to do pls explain with example my o/p should come for recent_date like =''01-23-2010''
    Edited by: user9112274 on Aug 27, 2010 5:31 AM

    Hi,
    there are numerous ways to compare dates, i give you some examples:
    with data_Sample as
    (select to_date('01-jan-2001','dd-mon-yyyy') d1, to_date('01-mar-2002','dd-mon-yyyy') d2, to_date('03-feb-2002','dd-mon-yyyy') d3 from dual)
    select greatest(d1,d2,d3) from data_Sample
    GREATEST(D1,D2,D3)
    3/1/2002
    with data_Sample as
    (select to_date('01-jan-2001','dd-mon-yyyy') d1 from dual union all
    select to_date('01-mar-2002','dd-mon-yyyy')   from dual union all
    select to_date('03-feb-2002','dd-mon-yyyy')  from dual)
    select max(d1) from data_Sample
    MAX(D1)
    3/1/2002
    declare
    d1 date :=to_date('01-jan-2001','dd-mon-yyyy');
    d2 date :=to_date('01-jan-2001','dd-mon-yyyy');
    begin
    if d1>d2 then
    dbms_output.PUT_LINE('d1 greater than d2');
    else
    dbms_output.PUT_LINE('d1 less or equql than d2');
    end if;
    end;
    output:
    d1 less or equal than d2now concerning your question:
    >
    can i use to_char to compare date
    >
    If you have date data types : don't convert them.
    if you have no choice, use something like:
    if to_char(d1,'YYYYMMDD') > to_char(d2,'YYYYMMDD') then
    else
    end if;Take care when you convert a date into a char format it becomes string comparison (with all it implies) (It's the reason why i've use an explicit mask format).

  • How to compare date with char

    hi
    i am having date from and date to feilds in my overtime element.i want to do the validation on these dates the the dates do not overlap or duplicated.the input value date from and date to are stored in database as varchar2 in the format yyyy/mm/dd 00:00:00. Now if i am trying to compare entered date with these dates i am getting literal does not match format string or date picture ends before....Can any body tell me what to do.
    Regards

    user10502390 wrote:
    hi
    i am having date from and date to feilds in my overtime element.i want to do the validation on these dates the the dates do not overlap or duplicated.the input value date from and date to are stored in database as varchar2 in the format yyyy/mm/dd 00:00:00. Now if i am trying to compare entered date with these dates i am getting literal does not match format string or date picture ends before....Can any body tell me what to do.
    RegardsPoint a) VERY BAD IDEA storing dates as VARCHAR2 on the database. It will only lead to corrupt data in the future.
    Point b) When comparing dates, you should compare them as DATE datatype as the database knows how to do comparisons against DATES. If you try and compare them as VARCHAR2 then you will most likely end up with incorrect comparisons.
    If you must have varchar2 storing of your dates/times (there's absolutely no reason to though)... you want...
    TO_DATE(:entered_date,'YYYY/MM/DD HH24:MI:SS') BETWEEN TO_DATE(DATEFROM,'YYYY/MM/DD HH24:MI:SS') AND TO_DATE(DATETO,'YYYY/MM/DD HH24:MI:SS')
    e.g.
    TO_DATE('20080815 13:23:33','YYYY/MM/DD HH24:MI:SS') BETWEEN TO_DATE(DATEFROM,'YYYY/MM/DD HH24:MI:SS') AND TO_DATE(DATETO,'YYYY/MM/DD HH24:MI:SS')

  • BC4J Query by example for dates uses wrong date format

    When querying by example on date fields, I get the following nested exceptions:
    oracle.jbo.SQLStmtException: JBO-27121: SQL error during statement execution.
    JBO-26044: Error while getting estimated row count for view object
    and
    java.sql.SQLException: ORA-01830: date format picture ends before converting entire input string.
    It would seem to be caused by the following clause added to the end of the entity object's query:
    "QRSLT WHERE ( ( (DATE_FIELD = TO_DATE('23/12/2003', 'yyyy-mm-dd')) ) )"
    which causes problems as our entity objects use a 'dd/MM/yyyy' date format.
    Is there a way we can make the query by example use the same date format as the rest of our app?

    I‘m not an expert on this but I see nobody is replying so this might help you. I've been having problems with dates as well and I‘m pretty sure that the attached formatter isn't used in find mode. That is because the java date class (can't remember which one) used by the BC4J has the format yyyy-mm-dd. I don't now if it is possible to change it but I got around the problem by writing my own domain. You can take a look at Toystore demo, by Steve Muench, that uses a custom date domain, ExpirationDate (see the code below). It is mapped to a VARCHAR column in the database but it is possible to map it to a DATE column.
    I have been watching the postings with questions about dates and I have noticed that a lot of people have problems with this but I haven’t seen an answer yet.
    package toystore.model.datatypes.common;
    import java.io.Serializable;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    import oracle.jbo.Transaction;
    import oracle.jbo.domain.DataCreationException;
    import oracle.jbo.domain.DomainInterface;
    import oracle.jbo.domain.DomainOwnerInterface;
    // --- File generated by Oracle Business Components for Java.
    * This custom datatype implements an immutable domain class that
    * maps to a VARCHAR column containing values like '10/2004' representing
    * expiration dates of credit cards. We could have chosen to implement
    * this as a domain that stores itself in a DATE column instead of a
    * VARCHAR column, but since the Java Pet Store demo schema stored the
    * information in a VARCHAR column, we decided to illustrate how to
    * accommodate that case using domains.
    public class ExpirationDate implements DomainInterface, Serializable {
    private Date mDate;
    private String mDateAsString;
    protected ExpirationDate() {
    mDate = new Date();
    convertDateToStringFormat();
    * Return the value of the expiration date as a java.util.Date
    public Date getDateValue() {
    return mDate;
    * Allow expiration date to be constructed from two
    * strings representing month and year
    public ExpirationDate(String monthVal, String yearVal) {
    this(monthVal+'/'+yearVal);
    public ExpirationDate(String val) {
    validate(val);
    convertDateToStringFormat();
    * The getData() method must return the type of object that JDBC will
    * see for storage in the database. Since we want this ExpirationDate
    * datatype to map to a VARCHAR column in the database, we return the
    * string format of the date
    public Object getData() {
    return mDateAsString;
    * <b>Internal:</b> <em>Applications should not use this method.</em>
    public void setContext(DomainOwnerInterface owner, Transaction trans, Object obj) {
    * Performs basic validation on strings that represent expiration dates
    * in the format of MM/YYYY. Note that in the process of testing whether
    * the string represents a valid month and year, we end up setting
    * the private member variable mDate with the date value, so if the
    * validate() method does not throw an exception, the mDate will be setup.
    protected void validate(String val) {
    if (val != null) {
    if (val.length() != 7 ||
    val.charAt(2) != '/' ||
    !isAllDigitsExceptSlashAtPositionTwo(val) ||
    !isValidMonthAndYear(val)) {
    throw new DataCreationException(ErrorMessages.class,
    ErrorMessages.INVALID_EXPRDATE,
    null,null);
    * Returns true if all digits except position 2 (zero-based) are digits
    private boolean isAllDigitsExceptSlashAtPositionTwo(String val) {
    for (int z=0, max = val.length(); z < max; z++) {
    if (z != 2 && !Character.isDigit(val.charAt(z))) {
    return false;
    return true;
    * Returns true if the val string, assumed to be in "MM/YYYY" format
    * is a valid month and year value, setting the mDate member variable
    * if they are valid.
    private boolean isValidMonthAndYear(String val) {
    try {
    int month = Integer.parseInt(val.substring(0,2));
    int year = Integer.parseInt(val.substring(3));
    Calendar c = Calendar.getInstance();
    c.setLenient(false);
    c.set(year,month-1,1); // Month is zero-based !
    mDate = c.getTime();
    catch (IllegalArgumentException i) {
    return false;
    return true;
    public String toString() {
    return mDateAsString;
    * Convert mDate to String format
    private void convertDateToStringFormat() {
    if (mDate != null) {
    SimpleDateFormat sdf = new SimpleDateFormat("MM/yyyy");
    mDateAsString = sdf.format(mDate);
    * Return true if the expiration date is in the future
    public boolean isFutureDate() {
    return mDate.compareTo(new Date())> 0;
    * Compare the Expiration Dates by comparing their respective
    * getData() values
    public boolean equals(Object obj) {
    if (obj instanceof DomainInterface) {
    Object thisData = getData();
    if (thisData != null) {
    return thisData.equals(((DomainInterface)obj).getData());
    return ((DomainInterface)obj).getData() == null;
    return false;

  • SQL: comparing date with datetime field

    I'm having a brain fart as I assume this is really simple.
    Given that I have the date in the format of yyyy/mm/dd, how
    do I put that
    into a sql query that compares that to the datetime field?
    It appears the datetime field, by default, uses this format:
    m/d/yyyy
    hh:mm:ss am
    -Darrel

    If your date formats are different you will have to use CAST
    or CONVERT
    functions as you state you already have. If this works then
    stick with it.
    You may also need to use a SET DATEFORMAT command. See below:
    http://msdn2.microsoft.com/en-us/library/ms189491.aspx
    Dates in SQL Server can be a bit of a pain to work with. It
    is usually best
    practice to store your DateTime data in raw format and use
    CAST or CONVERT
    functions in your Stored Procs to get the correct results.
    Pat.
    "darrel" <[email protected]> wrote in message
    news:ftloim$jv4$[email protected]..
    >
    >> What dbms?
    >
    > t-sql (MSSQL)
    >
    > For now, via string functions, I rearrange the date/time
    format manually,
    > and then use the CAST statement in the SQL query. Not
    pretty, but seems to
    > work.
    >
    > -Darrel
    >

  • Problem with SQL*Loader and different date formats in the same file

    DB: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    System: AIX 5.3.0.0
    Hello,
    I'm using SQL*Loader to import semi-colon separated values into a table. The files are delivered to us by a data provider who concatenates data from different sources and this results in us having different date formats within the same file. For example:
    ...;2010-12-31;22/11/1932;...
    I load this data using the following lines in the control file:
    EXECUTIONDATE1     TIMESTAMP     NULLIF EXECUTIONDATE1=BLANKS     "TO_DATE(:EXECUTIONDATE1, 'YYYY-MM-DD')",
    DELDOB          TIMESTAMP     NULLIF DELDOB=BLANKS          "TO_DATE(:DELDOB, 'DD/MM/YYYY')",
    The relevant NLS parameters:
    NLS_LANGUAGE=FRENCH
    NLS_DATE_FORMAT=DD/MM/RR
    NLS_DATE_LANGUAGE=FRENCH
    If I load this file as is the values loaded into the table are 31 dec 2010 and 22 nov *2032*, aven though the years are on 4 digits. If I change the NLS_DATE_FORMAT to DD/MM/YYYY then the second date value will be loaded correctly, but the first value will be loaded as 31 dec *2020* !!
    How can I get both date values to load correctly?
    Thanks!
    Sylvain

    This is very strange, after running a few tests I realized that if the year is 19XX then it will get loaded as 2019, and if it is 20XX then it will be 2020. I'm guessing it may have something to do with certain env variables that aren't set up properly because I'm fairly sure my SQL*Loader control file is correct... I'll run more tests :-(

  • Table_comparison - how to compare data at a high level

    Hi,
    I have to do data validation at a high level between two tables that I am loading.
    I am trying to use table_comparion transform but the problem is that my target table is at a much lower level than at which I want to compare data. So it has many more columns (both key and data fields) than what I want to compare.
    Does the output of query transform ( which I am using as input into table_comparion) be in the exact same format as comparion table? If not, then can somebody suggest me something else.
    Or how can I compare output of two query transforms ?
    Thanks,
    Saurabh Bansal

    Dear Saurabh,
    Not sure if you have already got the solution to this. If yes please close the thread.
    If not, i would suggest you can use the validation rule to compare the two tables and then based on the PASS or FAIL result can check what needs to be done on the output.
    Do post back if you have got the solution or you need any furthur help or else close the question.
    regards,
    Den

  • How to update the default date format in OBIEE 11G.

    Hi All,
    How to change the default date format in OBIEE 11g from the MM/DD to DD/MM. Could anyone please help me out ASAP?
    Thanks,
    Arpan

    Hi Arpan
    OBIEE 11g is having " localedefinitions.xml " file at this Location C:\Oracle\Middleware\Oracle_BI1\bifoundation\web\display
    in my case i installed at C:\Oracle\MIddleware.
    so
    1- Stop BI Server from EM
    2- Navigate to this Location C:\Oracle\Middleware\Oracle_BI1\bifoundation\web\display. in your case oracle home will be different
    3- take a backup of this file localedefinitions.xml "
    4- modify it and save
    5- bring BI Server up.
    Regards
    sher

  • Date format in Prompt

    Hi All,
    I am having a problem with the Date format in a Dashboard prompt. Using the following SQL for a default value, I get a date and time result, i.e. yyyy-mm-dd hh:min:ss
    SELECT CASE WHEN 1=0 THEN "Leach Center - Visits"."Visit Date"
    ELSE CAST(TIMESTAMPADD(SQL_TSI_YEAR, -1, CURRENT_DATE) AS DATE)
    END FROM "DSA - Leach Center"
    as soon as I click a new date in the calendar it goes to the right format of DD-MM-YYYY.
    Any Suggestions?

    Hi,
    I have the same problem and I try to fetch the patch 92800334 in Metalink/Support, but get no result back/not found. Any ideas??

  • Date format in xml file

    Hi,
    I am relatively new to XML and JSP.I am on a project where i have to transfer data to and from an Oracle 8i database to XML using JSP.everything worked fine except for the follwing:
    the date format in xml is always 'yyyy-mm-dd HH:MM:SS'.
    the datatype is date in oracle and string in jsp.when i try to upload the data in XML to oracle it gives me date format not recognised error.I ve tried using trunc and to_char in the query which fetches records into a recordset in JSP but to no avail.i keep getting the same format.
    Can someone please help with with having the date format as 'dd-mon-yyyy'.
    Thanks a heap for the help
    regards,
    Vinayak

    Hi,
    I ve tried out the solutions suggested by you and tried using java.sql.Timestamp
    as follow:
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="oracle.sql.*" %>
    String dateString = rset.getString("installation_dt");
    java.sql.Timestamp date = new java.sql.Timestamp.valueOf(dateString);
    But tomcat throws up the following error
    :104:
    cannot resolve symbol
    symbol : class valueOf
    location: class java.sql.Timestamp
    java.sql.Timestamp date = new java.sql.Timestamp.valueOf(dateString);
    Hope you can help me.
    Thanks a heap
    Regards,
    Vinayak

  • Date format in different databases like DB2, MS SQL, Oracle etc.

    Hi,
    Is there any standard date format, which works on any database like DB2, MS SQL Server, or Oracle 8i.
    Right now I am using specific format for each database.
    I am using the following syntax to retrieve the records on Jun 14, 2001.
    MS SQL Server:
    select * from tablename where
    CONVERT(character(10),ReceiptDateTime, 120) >='2001-06-14'
    and CONVERT(character(10), ReceiptDateTime , 120) <'2001-06-15'
    Oracle:
    select * from tablename where
    TO_CHAR(ReceiptDateTime,'YYYY-MM-DD') >= '2001-06-14'
    AND TO_CHAR(ReceiptDateTime,'YYYY-MM-DD') < '2001-06-15'
    Is there any way we can generalize the date formt?
    Any help appreciated.
    Thanks,
    Naidu

    Hi,
    Perhaps any difference when you compare the outcomes of
    SQL> select * from nls_database_parameters;
    SQL> select * from nls_session_parameters;on both databases?

Maybe you are looking for

  • After release 4.11 library OFGTEL differs from OFGTEL in former release

    Hi, After an update of Designer 6i to release 4.11 (coming from Designer 6i version 6.5.40.5.0) I have troubles regarding the Designer library OFGTEL.pll. In the library of the new version a procedure CGDV$REF_CODES.SOFT_VAL is adjusted, so that an e

  • Get url to open with a particular flash frame showing

    Sorry about this, it is my first time posting, hello to all. I have a site were I embed swf movies on individual html pages. I have a link/butt to open an html page but I need this page to open showing a particular frame in that embedded movie. I wou

  • Help understanding how to pass dates to procedures in a package?

    When I run the following script in SQL*Plus, I get no obvious errors, but the truncate does not happen and all the other processing doesn't happen. I ran a similar version in another tool and it worked. Much of the code is deleted here but I believe

  • Search to replicate filering of columns via dropdowns

    All, I've seen the following. It basically filters your columns in a "search" function, instead of filtering individual columns. How could I create my own version? Apologise, not even sure how to articulate what the search option does. Thanks W

  • Any way to manage installed updates in JDev 10.1.3?

    It's nice to have Help->Check for Updates... menu item. But is there any way to view what was updated? Any way to remove what was installed? We may need to try something and may find it is not what we want later... Thanks