Date formats for SQL statements used by recordset object

Hi,
Date formatting appears to be quite problematic for Business One.  I did a forum search for date issues and I don't think I saw any of them with an "answered" status.  I have an issue with formatting a date for the creation of an SQL statement that the DI sends to SQL Server 2005.  I need to format a date so that the localization parameters don't matter for either the client machine or SQL Server's machine.  We don't have a problem as long as our machines are localized as USA.
I have PL 22 and I have a form - ours - where I use the Today() function to fill a date field.  So this is a date that is not entered by the user.  The result of this function is consistent with the localization parameters on my machine.  We have two other date fields on the form where the user must type in the date. 
As a test, I changed my machine to the UK parameters.  I then set up the language parameters of Business One for English(United Kingdom).  I changed the date format specifications in Business One so that its format is dd/mm/yy.  I then brought up the form and the field that is formatted by the above function arrived in the form's field as dd/mm/yy.  I then typed in the two other dates in the same format and added the record to the database.  The form's table is user-defined. 
I dismissed the form then brought it back up loaded with the new record.  The date that was entered by the function appeared in USA format (mm/dd/yy).  The dates that were typed in appeared in the Business One format (dd/mm/yy).  This of course is not consistent.
When I looked at what got into the database, the formats were the opposite.  Weird!  To make matters really confusing, I run an SQL statement within SQL Server Mgt Studio, and use the WHERE clause to filter on the date that was based on the function.  It didn’t matter what format I used for the WHERE clause, the record came up.  Does anyone have any idea about how I can ensure that I always use the correct date format for SQL statements passed by Business One to SQL Server regardless of where in the world the application is being run?
Thanks,
Mike

Ian,
Here's what I'm concerned about:  I’m using the date in a “WHERE” clause.
Assume the date is Aug 3, 2007.
"SELECT * FROM Table WHERE StartDate > ‘8/3/2007’"
OR
"SELECT * FROM Table WHERE StartDate > ‘3/8/2007’"
If the client machine is set up as USA, the today function will provide the date as formatted in the first query.  If the database server is setup as let’s say the UK, I believe that SQL Server query parser will interpret the date as Mar 8, 2007.
If the client machine is set up as UK, the today function will provide the date as formatted in the second query.  If the database server is setup as let’s say USA, I believe that SQL Server query parser will also interpret the date as Mar 8, 2007.
In both cases it would be wrong.
I know I could use the DATEPART function to get the three parts and this will make the code indifferent to the localization specs of the client machine.  I need to then be able to concatenate those date parts for the “WHERE” clause so that the localization specifications of the database server don’t matter.
Thanks,
Mike

Similar Messages

  • Date format in SQL statements

    Hi there !
    Please, can anyone help me find out what is going on with date format in my SQL Statements ?
    While in development, the date format in SQL statements were:
    SELECT DATA_FIELD FROM TABLE WHERE DATE_COL = '10-DEC-2004'
    And works fine.
    After deploy to production server, we get ORACLE error: not a valid month
    So we change the format to
    SELECT DATA_FIELD FROM TABLE WHERE DATE_COL = '10/12/2004'
    And it gets to works again.
    Yesterday, the net administrator updated the JAVAC / JSDK run-time with Java update tool, and AGAIN we get ORACLE error: not a valid month
    So we change the format AGAIN to
    SELECT DATA_FIELD FROM TABLE WHERE DATE_COL = '10-DEZ-2004'
    And it gets to works again.
    What is going on ?
    JAVAC running on Windows2003.
    The application access the ORACLE DB directly through JDBC.
    There is no APPLICATION SERVER, like TOMCAT.
    The regedit (windows registry) ALWAYS was and are now :
    NLS_DATE_FORMAT = DD-MON-YYYY
    NLS_LANG = AMERICAN_AMERICA.WE8ISO8859P1
    Versions:
    DB Oracle 9.2.0.5.0
    JavaC 1.4.2.05
    Thanks.
    Juliano

    Somewhere, I'm willing to wager your NLS_DATE_FORMAT was/ is being changed. This is a client-side setting. Are you sure that the setting is the same on every client machine.
    This is one of the reasons that it is considered bad form to rely on implicit conversion. If you wrap your string literal in a TO_DATE, use the JDBC escape sequence {d }, or use a Date bind variable, you don't have this problem. The bind variable approach will also play much more nicely with your database's shared pool.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Buffer size for SQL statement using JDBC calls

    I need to find out the buffer size for SQL statements in jave/JDBC because I need to insert or update a field that could be up to 4KB in size.

    I'm not sure that I follow the question; I'm not sure which buffer size you're referring to.
    If you have a field that can store up to 4k worth of data, you would create a VARCHAR2(4000) column in the Oracle database (assuming it is character data) or a BLOB column (if the data is binary). Either of those two fields can be populated from JDBC.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Setting date format for the entire SQL Server installation - SQL Server 2008 R2-2012

    Hi,
    I need to safeguard the behaviour of SQL codes that inserting into SQL tables with some date columns. For this purpose, I need to change the date format for the SQL instance and not using CONVERT and CAST.
    I've seen the SET DATE FORMAT statement, but if I use it, could I solve my problem?
    Thanks

    The language setting is related to the database user.
    BOL: "DEFAULT_LANGUAGE = { NONE | <lcid> | <language name> | <language alias> }              
    Specifies the default language for the new user. If a default language is specified for the user and the default language of the database is later changed, the users default language remains as specified.
    If no default language is specified, the default language for the user will be the default language of the database. If the default language for the user is not specified and the default language of the database is later changed, the default
    language of the user will change to the new default language for the database."
    LINK: http://technet.microsoft.com/en-us/library/ms173463.aspx
    The default language setting can be overridden by SET LANGUAGE for the session:
    http://technet.microsoft.com/en-us/library/ms174398.aspx
    Example:
    SET LANGUAGE us_english; -- mdy
    SELECT CAST ('12/13/2014' as DATE); -- 2014-12-13
    GO
    SET LANGUAGE british; -- dmy
    SELECT CAST ('12/13/2014' as DATE);
    GO
    (1 row(s) affected)
    Changed language setting to British.
    Msg 241, Level 16, State 1, Line 2
    Conversion failed when converting date and/or time from character string.
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • XML SQL format for Prepared statements in batch mode

    Hi
    I want to use the batch mode in JDBC adapter for inserting huge volume of records with better performance.
    so i need to execute the prepared statements in one batch.   Is the XML SQL format for prepared statements below correct ?to<root>
      <stmt>
        <Customers action="SQL_DML">
          <access> INSERT INTO Customers (CompanyName,Address,CustomerID) VALUES($NAME$,$ADDRESS$,$KEYFIELD$)
          </access>
          <key>
            <NAME>IBM</NAME>
            <ADDRESS>Street 3 </ADDRESS>
            <KEYFIELD>CO</KEYFIELD>
          </key>
          <key>
            <NAME>PWC</NAME>
            <ADDRESS>Street 4 </ADDRESS>
            <KEYFIELD>NO</KEYFIELD>
         </key>
        </Customers>
      </stmt>
    </root>
    Please advise

    Hello Experts
    Please throw some light on the above question.
    Thanks in advance.

  • 'Missing select' error for update statement using WITH clause

    Hi,
    I am getting the below error for update statement using WITH clause
    SQL Error: ORA-00928: missing SELECT keyword
      UPDATE A
      set A.col1 = 'val1'
         where
      A.col2 IN (
      WITH D AS
      SELECT col2 FROM
      (SELECT col2, MIN(datecol) col3 FROM DS
      WHERE <conditions>
        GROUP BY PATIENT) D2
      WHERE
      <conditions on A.col4 and D2.col3>

    Hi,
    The format of a query using WITH is:
    WITH  d  AS
        SELECT  ...  -- sub_query
    SELECT  ...   -- main query
    You don't have a main query.  The keyword FROM has to come immediately after the right ')' that ends the last WITH clause sub-query.
    That explains the problem based on what you posted.  I can't tell if the real problem is in the conditions that you didn't post.
    I hope this answers your question.
    If not, post a complete test script that people can run to re-create the problem and test their ideas.  Include a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Error while retrieving data from PL/SQL Table using SELECT st. (Urgent!!!)

    Hi Friends,
    I am using Oracle 8.1.6 Server, & facing problems while retrieving data from a PL/SQL Table:
    CREATE or REPLACE PROCEDURE test_proc IS
    TYPE tP2 is TABLE of varchar2(10); --declared a collection
    dt2 tP2 := tP2('a','b','c');
    i NUMBER(8);
    begin
    SELECT COUNT(*) INTO i FROM TABLE(CAST(dt2 as tP2));
    DBMS_OUTPUT.PUT_LINE('**'||i);
    end;
    While executing the above procedure, I encountered foll. error:
    ERROR at line 1:
    ORA-00600: internal error code, arguments: [15419], [severe error during PL/SQL execution], [], [],
    ORA-06544: PL/SQL: internal error, arguments: [pfrrun.c:pfrbnd1()], [], [], [], [], [], [], []
    ORA-06553: PLS-801: internal error [0]
    Can anyone please help me, where the problem is??
    Is it Possible to retrieve data from PL/SQL TABLE using SELECT statement? & How ?
    Thanks in advance.
    Best Regards,
    Jay Raval.

    Thanks Roger for the Update.
    It means that have to first CREATE TYPE .. TABLE in database then only I can fire a Select statement on that TYPE.
    Actually I wanted to fire a Select statement on the TABLE TYPE, defined & declared in PLSQL stored procedure using DECLARE TYPE .. TABLE & not using CREATE TYPE .. TABLE.
    I was eager to know this, because my organization is reluctant in using CREATE TYPE .. TABLE defined in the database, so I was looking out for another alternative to access PL/SQL TABLE using Select statement without defining it database. It would have been good if I could access a PLSQL TABLE using Select statement Declared locally in the stored procedure.
    Can I summarize that to access a PL/SQL TABLE using SELECT statement, I have to first CREATE TYPE .. TABLE?
    If someone have any other idea on this, please do let me know.
    Thanks a lot for all help.
    Best Regards,
    Jay Raval.
    You have to define a database type...
    create type tP2 is table of varchar2(10)
    CREATE OR REPLACE PROCEDURE TEST_PROC
    IS
    dt2 tP2 := tP2('a','b','c');
    i NUMBER(8);
    begin
    SELECT COUNT(*) INTO i FROM TABLE(CAST (dt2 AS tP2));
    DBMS_OUTPUT.PUT_LINE('**'||i);
    end;
    This will work.
    Roger

  • While creating the Data source for Sql server am getting this error?

    Hi i new to Power BI sites and office 365,
    For my first step 
    1. i have successful creaeted Gateway in Office 365
    2.Now i have creating  the Data source for that gateway using Sql server R2
    3.While Creating the Data source using the Corresponding gateway i have given and next phase set Credentials  phase i have noticed one pop up window and it will shows me like
    Data source Settings and  below in that window it will show's u the things like 
    Datasource Name.
    Loading......
    Credentials type:
    Privacy Level:
    Failed to verify parameter
    I will get this results finally  ,so hw should i achive this probelm ,Please let me know if any one knows
    So kindly give me the proper answer for this.
    Regards

    Any suggestions for Chinnarianu?
    Thanks!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Update date format in SQL developer

    I need to convert date format in SQL developer , it's varchar2 format now
    The current format is yyyy/mm/dd-hh:mm:ss:sss and I need to convert it to yyyy-mm-dd hh:mm:ss CST
    I don't really know SQL but did some research and found that I can use instr to find the string and replace it, however, no matter what I try,there is always something off :(
    Could anyone here help me with it? thanks in advance.

    create table xo_custom_date_format (mydateAsChar varchar2(100));
    table XO_CUSTOM_DATE_FORMAT created.
    insert into xo_custom_date_format
    values ('2012/03/23-09:52:24:123')
    +1 rows inserted.+
    select mydateasChar from xo_custom_date_format
    mydateaschar
    +2012/03/23-09:52:24:123+
    select to_timestamp(mydateaschar, 'YYYY/MM/DD-HH24:MI:SS:FF3') mydateAsTimestamp from xo_custom_date_format
    -- We must convert to timestamp data type, rather than date data type as you have fractions of seconds
    mydateAsTimestamp
    +23-MAR-12 09:52:24.123000000 --<-- This will probably appear differently, depending on your database NLS_ settings (i.e. what country you are in)+
    select to_char( to_timestamp(mydateaschar, 'YYYY/MM/DD-HH24:MI:SS:FF3') , 'YYYY-MM-DD HH24:MM:SS')||' CST' as myDateReformatted
    from xo_custom_date_format
    mydateReformatted
    +2012-03-23 09:03:24 CST+

  • How to change date format for prentation variable

    Hi experts
    In my prompt the date format is MM/DD/YYYY . I have created one presentation variable for that but i want to use this in Formula as well in Title as: DD-MON-YY
    So how can i achieve it..
    Thanks in advance
    Regards
    Frnds

    Hi
    i think this can't be done through any code like oracle uses to_char, to_date function.
    Just follow this
    http://oraclebizint.wordpress.com/2007/12/19/oracle-bi-ee-101332-dates-dates-and-dates/
    With this, wherever you have this column, you will be getting this format dates..
    if you don't want in reports you can change it by mentioning the data format for that paricular column in report, but for the same column, if you want different format at different places (for prompts), you can't do that..

  • Where does one manage date formats for display and input

    the user specification is that dates be displayed as YYYY-MON-DD. Is there a config or properties file which contains the date format for display? Is there a calendar drop-down that can be positioned next to a date input field for a question on a screen?
    Thanks,
    Allan

    Hi Allan,
    Curious why the rule project wasn't created with "English (Canada)" initially? If your project is English (UK) with the default configurations for that locale, then I assume your currency values are appearing in OWD with the GBP symbol (£) instead of a dollar sign ($)?
    As for the impact of switching… I highly recommend getting confirmation from the OPA Dev team before doing it, but in the meantime, if you wanted to experiment on your own with a separate test rulebase (as opposed to whatever formal rulebase you're working on), here are my observations from an initial look… (FYI, I'm an experienced OPA rulie, but I'm non-technical and not in the Dev team, so best to check with them!)
    I poked around the language parser files and saw that English (UK) has an English (UK) verb list, whereas English (Canada) uses the English (US) verb list. The vast majority of verbs are identical in all the variations of English, however, there are a couple which differ. So if you've used any verbs which have a different spelling between the 2 lists, there may be some attribute text to tweak, e.g.
    - English (UK): the person travelled to Australia
    - English (US): the person traveled to Australia
    - English (UK): the person cancelled the reservation
    - English (US): the person canceled the reservation
    I saw some other different files between English (Canada) vs English (UK), but didn't notice anything in them which I'd expect to impact the rulebase.
    As for how it might impact other components:
    * screens file and the properties file – May be some tweaking depending on how you addressed the verb spelling issue above.
    * regression test files – May be some tweaking depending on how you addressed the verb spelling issue above.
    * messages.(locale).properties – The default messages.(locale).properties file appears to be based on the Language setting of the Project. I just tested this and OWD used a different messages.(locale).properties file when I changed the Project Language (OPM | File menu | Project Properties | Common Properties | General | Language).
    * Siebel Connector – don't know what the impact would be.
    OPA Dev team – Can you review what I've said here? And add any relevant further detail?
    Cheers,
    Jasmine

  • Supported date formats for sorting

    Can someone point me to a document describing the supported
    date formats for sorting? I mean, how should I format a date column
    in an XML dataset in order to have this column correctly sorted
    using the Spry framework?
    Thank you and sorry if the question is trivial.

    Thanks, what I have done for the moment as a temporary
    solution is to use the two date formats and have them both inside
    the one cell in the table (the column for the sortable date
    yyyy-mm-dd). In my CSS I have created a style for the first date
    that has it's visibility as hidden. That way it's sorting the Date1
    but only Date2 is being shown to the users as the other cells have
    more than one line of text it doesn't look too off centre.
    <div spry:region="ds2">
    <table width="662">
    <tr>
    <th width="127" class="eventhead"
    spry:sort="Date1">Date</th>
    <th width="151" class="eventhead"
    spry:sort="Type">Type</th>
    <th width="146" class="eventhead"
    spry:sort="Title">Title</th>
    <th width="189" class="eventhead"
    spry:sort="Venue">Venue</th>
    </tr>
    <tr spry:repeat="ds2" spry:setrow="ds2">
    <td height="53" class="event">{Date2}<span
    class="eventhide">{Date1}</span></td>
    <td class="event">{Type}</td>
    <td class="event">{Title}</td>
    <td class="event">{Venue}</td>
    </tr>
    </table>
    </div>
    </div>
    It seems to be working for the moment...

  • CalendarUI element showing different date format for different locations

    Hi,
    I have an input field with date calendar in my webdynpro Java form . User can select date from this calendar and fill the input field. For this I have used input field  in my layout and have binded this with one context attribute of type date. Say name of this field is requiredByDate
    Now when I build and deploy my code, I can see the the required By date field and user is able to select date values from the calendar button next to the input field. The format of the date selected is mm/dd/yyyy.
    However , when a user tests this application from other location say Malaysia, for him the format is coming as dd/mm/yyyy after selecting the date from the calendar.
    Just want to know ,is there is difference in date format for differnt locations ? For India, when you select the date its showing mm/dd/yyyy and for Malayisa its showing dd/mm/yyyy.
    Is there anything we can do by changing our system settings like timezone or dateformat in system settings.
    I am using standard UI element and binding it with context element of type date.
    Need your advice or help on this..
    Thanks and regards,
    Sai

    Hi,
    go to
    [http://help.sap.com/saphelp_nw04/helpdata/en/f4/d95664da179b4db731e21c2e470b72/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/en/f4/d95664da179b4db731e21c2e470b72/frameset.htm]
    It describes the fallback sequence followed by the Web Dynpro for Java Runtime in order to determine the current session locale.
    Regards
    Matteo

  • Changing date format for some of the date columns in a subject area

    Hi,
    I have a requirement to change the date format for some of the date columns to dd-mon-yyy for only a particular subject area. Is there a feature available in the RPD which can help me do this?
    In Answers - Column Properties for a Particular column of a report, we can save the style and formatting as system wide default for the particular column or the data type, but that applies across subject areas.
    I tried with the config files too , but that too applies to all suject areas.
    Thanks in Advance,
    Gaurav

    Why don't you create 2 logical column derived from same date physical col and then change the format for one logical column and use it in Subject Area ?

  • Switzerland ESR file format for Bank statement upload

    Hi,
    I want to how the Switzerland ESR file format for bank statement upload looks like?
    Can i get the sample of the file format from anywhere?
    I just want to input this file to program RFEBCH00 to convert it into multicash file format.
    Please if anybody can help regarding this?
    Thanks,

    Hi Gordon,
    Thank you so much for your welcome and prompt reply. The localization is Chinese. But the client is using HSBC service which only provides swift MT940 format. I believe Dutch is included in the system of 2007A. Unfortunately, our system is 2007B. Is there any chance I can download the bfp file from SAP portal site or other places? Thank you very much again for your help. I am looking forward to hear from you!
    Cheers,
    Leon

Maybe you are looking for

  • Upgrade from SCM 5.1 to SCM 7.0 SR1 (with NW 7.0 EHP1 SR1)

    Hi folks, we are trying to upgrade our SCM5.1 to SCM 7.0 SR1. There seems to be a problem in the phase, where SAPup is trying to detect the needed CDs / DVDs. SAPup recognizes that "FRP" is used within the system. There appears a dialog to enter the

  • Publish is gone from my menu; how do I find the url of a calendar to shar?

    I used to publish calendars, but publish doesn't come up as an option. I tried sharing, but the people I want to share with don't have MobileMe. I made the calendar share with everybody, but I don't know how to find its address to give to people. I l

  • Audigy 4 (Non Pro) and center channel surround sound - from 2 channel aud

    Hi all,?Is there a way to have voice coming from the center speaker during TV programs like you could using an external receiver with Pro Logic? I can't for the life of me, get my Audigy 4 to do this. I run MCE 2005 on a couple of machines in the hou

  • Search and index for child projects

    Hello I have a merged RoboHelp 9 project.  Is there a way I can setup the project so that when the user does a search, the child projects are searched as well as the master?  Is there a way that I can used the Smart Index Wizard from the master proje

  • Changing Subreport filter in VBA

    I have a form "PriceListPrint" that has a field named "CategoryID" and command button to open a report "PriceListEnglish". In the form before the open report command there is this line: CategoryID="Rest" In the report there is a subreport "PriceListB