Date Calculation fails on Converted Access to Oracle Migration

I have converted an Access application to oracle database.
A select query calculates the months between the system date and a date stored in the Oracle Tables and it works you can view the results.
Another program using this query as source fails with a message
ODBC--Call Failed
[Oracle][ODBC][Ora]ORA-30081:invalid data type for datetime/interval arithmetic(#30081
This select query works displays the calculated “MONTHS_OLD” column
SELECT PR_main.PR_NUMBER, PR_main.SUBMISSION_DATE, Int((Now()-PR_main!submission_date-1)/30) AS Months_old, Int(Now()-[PR_main]![submission_date]) AS Days_old, PR_main.PROGRAM_ID, ATA_chapter_list.ATA_FUNCTIONAL_GROUP, PR_main.CURRENT_STATE
FROM PR_main INNER JOIN ATA_chapter_list ON PR_main.ATA_CHAPTER = ATA_chapter_list.ATA_CHAPTER_NUMBER
WHERE (((PR_main.CURRENT_STATE) Not Like "*Closed*"));
This query using the query above as the source, gives you the error
SELECT Count(ATA_time_query!pr_number) AS Count30, ATA_time_query.ATA_FUNCTIONAL_GROUP, ATA_time_query.PROGRAM_ID
FROM ATA_time_query
WHERE (((ATA_time_query.Months_old)<1))
GROUP BY ATA_time_query.ATA_FUNCTIONAL_GROUP, ATA_time_query.PROGRAM_ID;

I dont understand what you are asking? I think u are saying a part of our transformation is not right? Can you be specific about the function or where this is broken for you?

Similar Messages

  • Fusion Apps web service call fails with error access denied (oracle.wsm.security.WSFunctionPermission)

    Hello Guru,
    I am trying to call a supplier service from SOA/OSB.
    But while calling the service it is failing with the below error message
    access denied (oracle.wsm.security.WSFunctionPermission http://xmlns.oracle.com/apps/prc/poz/suppliers/supplierService/SupplierService#getSupplierVO invoke)
    As per OER cookbook i have attached the "oracle/wss_username_token_client_policy" to the Fusion  apps web service.
    I am trying to pass security credentials to the service by using all the methods... through composite ..through bpel through wsse header but in all cases i am getting similar error.
    Please let me know if some one has called the fusion apps web service to create a supplier of solution to my problem  as mentioned above.

    Hi Sai,
        Thanks for the quick and correct response. Yes, after doing the research, I'm also came to same conclusion. But what stops me here is that where exactly I need to check for this permission.
    I mean the theory what I built on this Authorization/Permission is that:
       For the resource - WebService (SupplierService), there is an assigned application role for which the Entitlement/Permission is provided.
    Pls. help me in the below items:
    a. What is the application role(in role hierarchy) assigned to this resource(Webservice). Which page I need to check(navigation) this and the required credentials..
    b. What is the Entitlement provided for this application role for this operation (getSupplierVO) invoke.. Which page I need to check(navigation) this and the required credentials..
    Thanks in Advance.
    Thanks & Regards
    Madhu

  • FusionApps web service call fails with error access denied (oracle.wsm.security.WSFunctionPermission)

    Hi Gurus,
    I started test this webservice from EM (Test Web Service)
    But while calling the service it is failing with the below error message
    access denied (oracle.wsm.security.WSFunctionPermission http://xmlns.oracle.com/apps/prc/poz/suppliers/supplierService/SupplierService#getSupplierVO invoke)
    As per OER cookbook i have attached the "oracle/wss_username_token_client_policy" to the Fusion  apps web service.
    I am trying to pass security credentials to the service by using all the methods... through composite ..through bpel through wsse header but in all cases i am getting similar error.
    Please let me know if some one has called the fusion apps web service to create a supplier of solution to my problem  as mentioned above.
    Is it any policy error or the authorization error ...
    Are there any navigation steps I can check the existed permission on this resource etc..,
    Thanks in Advance

    Hi Sai,
        Thanks for the quick and correct response. Yes, after doing the research, I'm also came to same conclusion. But what stops me here is that where exactly I need to check for this permission.
    I mean the theory what I built on this Authorization/Permission is that:
       For the resource - WebService (SupplierService), there is an assigned application role for which the Entitlement/Permission is provided.
    Pls. help me in the below items:
    a. What is the application role(in role hierarchy) assigned to this resource(Webservice). Which page I need to check(navigation) this and the required credentials..
    b. What is the Entitlement provided for this application role for this operation (getSupplierVO) invoke.. Which page I need to check(navigation) this and the required credentials..
    Thanks in Advance.
    Thanks & Regards
    Madhu

  • Error: Access to Oracle migration

    am trying to migrate MS access to oracle using Oracle work bench but my tables are empty. Getting error
    Unable to migrate data from source table "SUMMARY_OF_METHODS_1" to destination table billing.SUMMARY_OF_METHODS_1 :
    [Microsoft][ODBC Microsoft Access Driver] Could not find file "(unknown)".
    I have checked that I have proper user dsn for Ms Access database.
    I have xml file in same folder where .mdb is.

    Please refer to MS Access Data Migration posting.

  • MS Access  to Oracle Migration

    I have downloaded the plugins from http://www.oracle.com/technology/software/tech/migration/workbench/index.html and I dont see any MSAccess.jar file. i see a MSAccess.class file. Am i supposed to copy that to the omwb/plugins ?
    If i do that, it doesnt work. Were should I keep the other files of the plugins. Is there any rule? I am using Win XP and Oracle 9i release 2.
    Please Help.

    Hi Abu,
    I'm not sure of the exact steps you carried out, but hopefully your issue will be resolved if you do the following:
    1. As you did before, go to the Oracle Migration Workbench Downloads page, http://www.oracle.com/technology/software/tech/migration/workbench/index.html
    2. From section "3-Download the Plug-in for the Database You Want to Migrate", select "Microsoft Access Plugin" to start the download of the MSAccess.jar plug-in.
    3. Save the MSAccess.jar to the \plugins folder under your OMWB install e.g. D:\omwb\plugins.
    You should now have successfully downloaded the plugin. Restart the workbench in order to pick up the new plugin. If you are seeing an MSAccess.class file in your directory, I'm guessing that the jarfile was unpacked. You are not required to unpack the jarfile after you have downloaded it.
    I hope this helps.
    Regards,
    Hilary

  • Converting Access application after migrating SQL Server database

    I have used migration workbench to migrate an access database and application. I now have sql server databases with access applications that need to be migrated. How can I convert the access applications that currently use sql server as a database? I don't see that migration workbench considers this combination.

    If you have and Access/SQL Server combination. then download the SQL server plugin appropriate to your version of SQL server. Go ahead and migrate the SQL Server database to Oracle. Once this is done, then update your access application so your link tables point to your newly migrated Oracle database.
    Donal

  • Transfer of files from access to oracle

    i want to transfer the data base files of ms access to oracle. without using oracle navigator how should i transfer the files?

    This forum is for feedback about the OTN program and problems with OTN accounts. Technicalquestions cannot be answered here. Please post your question in the appropriate product or technology forum

  • To Convert Data From Access To Oracle

    Hi Allz,
    Is there any tool to convert mdb (microsoft data base) data to oracle 9i , because in oracle 8 there is Microsft Access Tool for Oracle, through that tool we can covert mdb data to oracle.How can we convert the same data in oracle 9i.
    Thanks

    You could use Oracles Migration Workbench
    http://www.oracle.com/technology/tech/migration/index.html

  • I want to convert date from Microsoft Access to Oracle.

    I want to convert date from Microsoft Access to Oracle.
    My Oracel date format is 21-Jul-2004 02:24:09 AM
    I use sqlldr in Oracle 9i Database and I
    write control file
    load data
    infile 'test.txt'
    into table test
    fields terminated by "," optionally enclosed by '"'
    trailing nullcols
    name,
    birthday
    data file 'test.txt' for input
    "dao","21-Jul-2004 02:24:09 AM"
    why did error? ORA-01843: not a valid month
    Thank.

    replace birthday with
    birthday "to_date(:birthday, 'DD-Mon-YYYY HH:MI:SS AM', 'NLS_LANGUAGE=''american''')"Of course, if your monthes are in German, then set the language to german (JUL=JUL but DEZ<>DEC)
    Regards
    Laurent

  • Fail to convert to internal representation: oracle.sql.DATE

    I'm using the oracle 8.1.7 jdbc driver against oracle 8.1.7 running on NT, and I get the exception message below when I attempt to insert an jpub object structure into a prepared statement.
    All date objects have been constructed from a timestamp object, using the oracle.sql.DATE Timestamp constructor. So I'm surprised to get this error given the timestamp object was successfully constructed.
    I've tried session date formats of 'yyyy-mm-dd hh24:mi:ss' and 'mm/dd/yyyy hh24:mi:ss', with no success.
    I can call stringValue on oracle.sql.DATE and it returns a valid date.
    Can someone confirm that they have been able to use the oracle.sql.DATE class to insert a date correctly into the database? Its seems a silly question to ask but you have to start somewhere!
    Exception : Fail to convert to internal representation: oracle.sql.DATE@3c144e8a
    Stack trace : java.sql.SQLException: Fail to convert to internal representation: oracle.sql.DATE@3c144e8a
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:829)
    at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTypeADT.java:261)
    at oracle.sql.StructDescriptor.toOracleArray(StructDescriptor.java:385)
    at oracle.sql.StructDescriptor.toArray(StructDescriptor.java:560)
    at oracle.sql.STRUCT.<init>(STRUCT.java:95)
    at oracle.jpub.runtime.MutableStruct.toDatum(MutableStruct.java:65)
    null

    The JPub/JDBC runtime is converting your Java object into Oracle-specific representation (all data is put in oracle.sql.XXXX format). The top level object is an oracle.sql.STRUCT, the attributes of which are represented as an array of oracle.sql.Datum objects - in your case an oracle.sql.NUMBER and an oracle.sql.DATE. However, the error does occur in the StructDescriptor which describes the SQL type and the shape of the object. Is the error dependent on the data values? Might null values not be dealt with, correctly?
    One thing to try to do is create such an oracle.sql.STRUCT object from scratch with the same attribute values and insert/manipulate that using SQL.
    I have not dealt with TAR's. If you send me a self-contained test case, I'll check it against the current development version of JDBC. (At least you'll know if the next JDBC release fixes this issue :-) I might also file a bug.

  • Data Migration from Microsoft Access to Oracle 9i

    Dear All
    This is my first request in your forum,My problem is that I have installed SQL developer but unable to migrate my MDB (Microsoft access file) into Oracle 9i,I have done the following activities in order to migrate data.
    open sql developer
    under migration,click quick migration
    quick migration wizard diaglog box appear,click new,
    in the oracle tab, input the following information
    input connection name 'zuhair',give user name and password (sys/s),check save password option,give role "sysdba" ,give connection type "basic",didnt check any any check box like os authorization and others,give host name 'zkhan-dfml',port '1521',sid 'dba' and then push the test button and then status show "success"
    in the access tab, input the following information
    input connection name ,input mdb file name by using browse button,after this step click test button then the following message display 'test fail odbc microsoft access driver not a valid password
    I have tried to create odbc link but i think i have done some thing wrong,kindly help
    Regards
    Zuhair

    Hi Zuhair,
    If you give details of the problems you are still having then we should be able to get SQL*Developer to work.
    However, if you don't want to use SQL*Developer then the following options are taken from note 393760.1 available in Metalink if you have access to that -
    1. Use a gateway that supports the non-Oracle database or generic connectivity if a third party ODBC driver is available to do a -
    'create Oracle_table as select from non_oracle_table@database_link'
    for each table. You would then have to manually create all the other objects (views, indexes, stored procedurs etc) and permissions etc that existed in the non-Oracle database.
    2. Use the SQL*Plus COPY command to copy data from the non-Oracle database to the
    Oracle database using a gateway or generic connectivity. The syntax is as follows:
    COPY FROM username/password@oracle_sid -
    INSERT destination_oracle_table -
    USING query;
    The following example selects all rows from the EMP table in the non-Oracle database and
    inserts them into the local Oracle EMP table:
    COPY FROM SCOTT/TIGER@ora10 -
    INSERT EMP -
    USING SELECT * FROM SCOTT.EMP@gateway;
    where "gateway" is the database link created for the gateway.
    3. Load the non-Oracle data into flat files and use SQL*Loader to put the data into Oracle tables. Again manual
    work is required for the other objects.
    4. Contact the Oracle Product Technology Services (PTS) group for assistance. See the webpage -
    http://www.oracle.com/technology/tech/migration//workbench/index_sqldev_omwb.html
    5. Use a third party migration tool. See -
    http://www.oracle.com/technology/tech/migration/isv/third_party.html
    6. Use JDBC to connect to the non-Oracle database and Java in the Oracle database. This method will work but it is not suppported by the JDBC team.
    =========
    The amount of work involved will depend on the number and size of Access tables that you want to migrate.
    Regards,
    Mike

  • Conversion failed when converting the varchar value 'undefined' to data typ

    Conversion failed when converting the varchar value 'undefined' to data type int.
    hi, i installed oracle insbridge following the instruction in the manual. in rate manager, when i tried to create a new "Normal rating" or "Underwriting", im getting the following exception
    Server Error in '/RM' Application.
    Conversion failed when converting the varchar value 'undefined' to data type int.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.Data.SqlClient.SqlException: Conversion failed when converting the varchar value 'undefined' to data type int.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    [SqlException (0x80131904): Conversion failed when converting the varchar value 'undefined' to data type int.]
    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1948826
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4844747
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
    System.Data.SqlClient.SqlDataReader.HasMoreRows() +157
    System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) +197
    System.Data.SqlClient.SqlDataReader.Read() +9
    System.Data.SqlClient.SqlCommand.CompleteExecuteScalar(SqlDataReader ds, Boolean returnSqlValue) +50
    System.Data.SqlClient.SqlCommand.ExecuteScalar() +150
    Insbridge.Net.Fwk.DAO.DataAccess.ScalarQuery(String connectionString, String command, Transaction transType, Object[] procParams) +110
    [Exception: Cannot Execute SQL Command: Conversion failed when converting the varchar value 'undefined' to data type int.]
    Insbridge.Net.Fwk.DAO.DataAccess.ScalarQuery(String connectionString, String command, Transaction transType, Object[] procParams) +265
    Insbridge.Net.Fwk.DAO.SqlProcessor.ExecuteScalarQueryProc(String subscriber, String datastore, String identifier, String command, Transaction transType, Object[] procParams) +101
    Insbridge.Net.Fwk.DAO.SqlProcessor.ExecuteScalarQuery(String subscriber, String identifier, String command) +22
    Insbridge.Net.RM.IBRM.ExeScalar(String cmd, Object[] paramsList) +99
    Insbridge.Net.RM.Components.Algorithms.AlgEdit.Page_Load(Object sender, EventArgs e) +663
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
    System.Web.UI.Control.OnLoad(EventArgs e) +99
    System.Web.UI.Control.LoadRecursive() +50
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
    my insbridge versions are as follows
    IBRU 4.0.0 Copyright ©2010, Oracle. All rights reserved. - Version Listing
    RMBUILD.DLL 4.0.0.0 (x86)
    SRLOAD.DLL 3.13.0 (x86)
    IBRM v04.00.0.17
    IB_CLIENT v04.00.0.00
    RM.DLL 4.00.0 (x86)
    IBFA 3.0.2
    OS: Windows Server 2003
    DB: Sql Server 2008
    Browser: IE8
    how do i solve this, please help

    This is an error due to conversion failed from character string to int datatype. Infact, the table column contains "NO" value which you are trying to convert to Int/SUM which is illegal. Without your code and table structure, its difficult to pinpoint your
    actual issue. But check, all columns for value "NO". 

  • Using Access forms after migrating data to Oracle

    Hi,
    One of the features provided by the original Migration Workbench appears to be the ability to modify a migrated Access database to use an ODBC connection to Oracle so that the original forms could still be used. I have just been through the process of migrating the demo Northwind database into Oracle using the SQL Developer Migration Workbench but this doesn't appear to be an option.
    I am missing something or is this feature not available using the migration tools in SQL Developer?
    And if it is missing what would be the easiest way to achieve this? From my limited exposure to Access converting the Northwind application manually appears to be rather painful.
    Many thanks,
    Vince

    Hi Vince,
    As you have correctly stated, the option to modify an MS Access database for the purpose of using the original forms is not available in Oracle SQL Developer Migration Workbench. As this option is no longer available, the easiest way to achieve the same result is to manually update your MDB file to reference the migrated Oracle tables. Once your MS Access Forms are referencing the link tables, you can continue using the forms as before. I would suggest doing the following:
    NOTE: These steps should only be carried out after you have migrated your tables from Access to Oracle using Oracle SQL Developer Migration Workbench. I would also recommend that you take a back-up of your MDB file before carrying out the following steps...just to be on the safe side!
    1. Create a new System DSM (using the ODBC Data Source Administrator dialog, via the Control Panel > Administrative Tools on your OS), using the connection details to access the newly migrated Oracle database schema. Test the connection, to ensure it's working correctly.
    2. Open your MDB file in database view - double-click the MDB file, holding down the Shift key.
    3. Remove the original Access tables.
    4. Using the Insert > Table menu item in MS Access, start the New Table wizard and create Link Tables to each of the migrated tables in your Oracle schema. NOTE: Rename the Link Table(s) so it matches the original Access table name. This will save you from having to edit each of the Forms, to change the Record Source it's based on. The form will still have a reference to the original table name, so by reusing the same name your form should just continue working as before. The only difference is that the data is being retrieved from the Oracle database now!
    If you have any questions regarding any of the above information, just respond to this thread & I'll get back to you.
    I hope this helps.
    Regards,
    Hilary

  • Conversion failed when converting date and/or time from character string

    Hi experts,
    I'm trying running a query in Microsoft Query but it gives the following error message:
    "conversion failed when converting date and/or time from character string"
    when asks me the data I'm inserting 31-01-2014
    i've copy the query form the forum:
    SELECT T1.CardCode, T1.CardName, T1.CreditLine, T0.RefDate, T0.Ref1 'Document Number',
         CASE  WHEN T0.TransType=13 THEN 'Invoice'
              WHEN T0.TransType=14 THEN 'Credit Note'
              WHEN T0.TransType=30 THEN 'Journal'
              WHEN T0.TransType=24 THEN 'Receipt'
              END AS 'Document Type',
         T0.DueDate, (T0.Debit- T0.Credit) 'Balance'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')<=-1),0) 'Future'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=0 and DateDiff(day, T0.DueDate,'[%1]')<=30),0) 'Current'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>30 and DateDiff(day, T0.DueDate,'[%1]')<=60),0) '31-60 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>60 and DateDiff(day, T0.DueDate,'[%1]')<=90),0) '61-90 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>90 and DateDiff(day, T0.DueDate,'[%1]')<=120),0) '91-120 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=121),0) '121+ Days'
    FROM JDT1 T0 INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
    WHERE (T0.MthDate IS NULL OR T0.MthDate > ?) AND T0.RefDate <= ? AND T1.CardType = 'C'
    ORDER BY T1.CardCode, T0.DueDate, T0.Ref1

    Hi,
    The above error appears due to date format is differnt from SAP query generator and SQL server.
    So you need convert all date in above query to SQL server required format.
    Try to convert..let me know if not possible.
    Thanks & Regards,
    Nagarajan

  • Error "Conversion failed when converting date and/or time from character string" to execute one query in sql 2008 r2, run ok in 2005.

    I have  a table-valued function that run in sql 2005 and when try to execute in sql 2008 r2, return the next "Conversion failed when converting date and/or time from character string".
    USE [Runtime]
    GO
    /****** Object:  UserDefinedFunction [dbo].[f_Pinto_Graf_P_Opt]    Script Date: 06/11/2013 08:47:47 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE   FUNCTION [dbo].[f_Pinto_Graf_P_Opt] (@fechaInicio datetime, @fechaFin datetime)  
    -- Declaramos la tabla "@Produc_Opt" que será devuelta por la funcion
    RETURNS @Produc_Opt table ( Hora datetime,NSACOS int, NSACOS_opt int)
    AS  
    BEGIN 
    -- Crea el Cursor
    DECLARE cursorHora CURSOR
    READ_ONLY
    FOR SELECT DateTime, Value FROM f_PP_Graficas ('Pinto_CON_SACOS',@fechaInicio, @fechaFin,'Pinto_PRODUCTO')
    -- Declaracion de variables locales
    DECLARE @produc_opt_hora int
    DECLARE @produc_opt_parc int
    DECLARE @nsacos int
    DECLARE @time_parc datetime
    -- Inicializamos VARIABLES
    SET @produc_opt_hora = (SELECT * FROM f_Valor (@fechaFin,'Pinto_PRODUC_OPT'))
    -- Abre y se crea el conjunto del cursor
    OPEN cursorHora
    -- Comenzamos los calculos 
    FETCH NEXT FROM cursorHora INTO @time_parc,@nsacos
    /************  BUCLE WHILE QUE SE VA A MOVER A TRAVES DEL CURSOR  ************/
    WHILE (@@fetch_status <> -1)
    BEGIN
    IF (@@fetch_status = -2)
    BEGIN
    -- Terminamos la ejecucion 
    BREAK
    END
    -- REALIZAMOS CÁLCULOS
    SET @produc_opt_parc = (SELECT dbo.f_P_Opt_Parc (@fechaInicio,@time_parc,@produc_opt_hora))
    -- INSERTAMOS VALORES EN LA TABLA
    INSERT @Produc_Opt VALUES (@time_parc,@nsacos, @produc_opt_parc)
    -- Avanzamos el cursor
    FETCH NEXT FROM cursorHora INTO @time_parc,@nsacos
    END
    /************  FIN DEL BUCLE QUE SE MUEVE A TRAVES DEL CURSOR  ***************/
    -- Cerramos el cursor
    CLOSE cursorHora
    -- Liberamos  los cursores
    DEALLOCATE cursorHora
    RETURN 
    END

    You can search the forums for that error message and find previous discussions - they all boil down to the same problem.  Somewhere in your query that calls this function, the code invoked implicitly converts from string to date/datetime.  In general,
    this works in any version of sql server if the runtime settings are correct for the format of the string data.  The fact that it works in one server and not in another server suggests that the query executes with different settings - and I'll assume for
    the moment that the format of the data involved in this conversion is consistent within the database/resultset and consistent between the 2 servers. 
    I suggest you read Tibor's guide to the datetime datatype (via the link to his site below) first - then go find the actual code that performs this conversion.  It may not be in the function you posted, since that function also executes other functions. 
    You also did not post the query that calls this function, so this function may not, in fact, be the source of the problem at all. 
    Tibor's site

Maybe you are looking for