Wrong Date format in SQL Server

Hello All,
I have an asp page with a hidden field that holds
<%=Date()%>. Because the
Session.LCID is set to UK this value today would be
12/03/2007 (UK format).
When this hidden field is fed into an INSERT Stored Procedure
in SQL Server
in my testing environment, the date format that is inserted
into the
database is the same as the value in the hidden field eg
12/03/2007, which
is what I want.
Now though, the site has moved to a production web server
with SQL Server.
When I perform this exact insert using the same webpages and
(from what I
can see) the same SQL Server configuration, the date inserts
as 03/12/2007,
US format. This is causing me big problems as the website is
complete but
the wrong dateformat is producing some undesirable results.
The whole site
is set up to expect the original format and I cannot see why
this is
happening.
Does anyone have any suggestions and more importantly how I
can change this
please.

There is a real issue here and it has nothing to do with the
way that data
is formatted on the way out.
msSQL does seem to always assume that numbers entered in the
format of
00/00/00 follow the pattern of MM/DD/YY which is American
format. So the 8th
of March entered in UK format of 08/03/2007 ends up being
intrepreted by SQL
as 3rd August. However it only does this up to the 12th of
each month. If
you enter the 13th of March as 13/03/2007 SQL stores it
correctly.
The workaround does seem to enter the number in the
YYYY-MM-DD format as
Julian has suggested.
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver
Valleybiz Internet Design
www.valleybiz.net
"Lionstone" <[email protected]> wrote in
message
news:[email protected]...
> SQL Server does not store dates in any format. They are
simply numbers,
> with the integer part representing date and the
fractional part
> representing time. If you do not format dates on the way
out, then you're
> leaving things up to your web server (and depending on
when the dates
> become strings, it might be the ADO provider and not ASP
that does the
> formatting).
>
> The only way to reliably format dates the way you want
is to do so
> explicitly. You may use CONVERT for SQL Server and
specify a format
> option (
http://msdn2.microsoft.com/en-us/library/aa226054(SQL.80).aspx),
> or you may use the FormatDateTime function in your ASP
page.
> FormatDateTime is locale-aware when it formats dates.
All you have to do
> is make sure the locale is set properly (which you seem
to have done).
>
>
>
> "TTal" <[email protected]> wrote in message
> news:[email protected]...
>> Hello All,
>>
>> I have an asp page with a hidden field that holds
<%=Date()%>. Because
>> the Session.LCID is set to UK this value today would
be 12/03/2007 (UK
>> format).
>>
>> When this hidden field is fed into an INSERT Stored
Procedure in SQL
>> Server in my testing environment, the date format
that is inserted into
>> the database is the same as the value in the hidden
field eg 12/03/2007,
>> which is what I want.
>>
>> Now though, the site has moved to a production web
server with SQL
>> Server. When I perform this exact insert using the
same webpages and
>> (from what I can see) the same SQL Server
configuration, the date inserts
>> as 03/12/2007, US format. This is causing me big
problems as the website
>> is complete but the wrong dateformat is producing
some undesirable
>> results. The whole site is set up to expect the
original format and I
>> cannot see why this is happening.
>>
>> Does anyone have any suggestions and more
importantly how I can change
>> this please.
>>
>
>

Similar Messages

  • Data services with SQL Server 2008 and Invalid time format variable

    Hi all
    Recently we have switched from DI on SQL Server 2005, to DS(Date Services) on SQL Server 2008. However I have faced an odd error on the query that I was running successfully in DI.
    I validate my query output using a validation object to fill either Target table (if it passes), or the Target_Fail table (if it fails). Before sending data to the Target_Fail table, I map the columns using a query to the Target_Fail table. As I have a column called 'ETL_Load_Date' in that table, which I should fill it with a global variable called 'Load_Date'. I have set this global variable in the script at the very first beginning of the job. It is a data variable type:
    $Load_Date = to_char(sysdate(),'YYYY.MM.DD');
    When I assign this global variable to a datetime data type cloumn in my table and run the job using Data Services, I get this error:
    error message for operation <SQLExecute>: <[Microsoft][ODBC SQL Server Driver]Invalid time format>.
    However I didn't have this problem when I was running my job on the SQL Server 2005 using Data Integrator. The strange thing is that, when I debug this job, it runs completely successfully!!
    Could you please help me to fix this problem?
    Thanks for your help in advance.

    Thanks for your reply.
    The ETL_Date is a datetime column and the global variable is date data type. I have to use the to_char() function to be able to get just the date part of the current system datetime. Earlier I had tried date_part function but it returns int, which didn't work for me.
    I found what the issue was. I don't know why there were some little squares next to the name of the global variable which I had mapped to the ETL_Date in the query object!!! The format and everything was OK, as I had the same mapping in other tables that had worked successfully.
    When I deleted the column in the query object and added it again, my problem solved.

  • 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

  • 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

  • PJC Calendar setDate Wrong date format. Date change failed?

    Forms 10.1.2 using forms demos pjc code.
    The calendar pjc I added to my form works except I can't initialize it with a date. If I try to initialize a date it always produces 'Wrong date format. Date change failed.' error.
    In a post-query trigger, I initialize the calendar's date using:
    SET_CUSTOM_PROPERTY('PJC.CALENDAR',1,'setDate',to_char(:lead.date_received,'DD.MM.YYYY'));
    In the java console, this yields:
    Warning: Wrong date format. Date change failed.
    Warning: Wrong date format. Date change failed.
    I get the same result when using a hardcoded date like:
    SET_CUSTOM_PROPERTY('PJC.CALENDAR',1,'setDate','01.12.2006');
    What is the flaw in my incantation?

    Hello,
    This is the syntax used in the calendarpjc Forms demo:
        call the setDate method on the calendar PJC via the PL/SQL built in
        set_custom_item_property
        convert Oracle date to String recognised by Java
      procedure setDate(d in date) is
      begin
        set_custom_property(lGlobals.hCalendar,1,'setDate',to_char(d,'Mon DD, YYYY'));
      end;     Francois

  • Plz its URGENT : Storing unicode data in MS SQL Server 2000 through JSPs

    Hello All,
    I'm trying to store unicode data, entered from JSP page into the SQL Server. For that I've tried the following :
    1> I put tag -
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    2> Also set in JSP tag -
    <%@page contentType="text/html;charset=UTF-8"%>
    But, still data is being entered in ISO-8859-1 format, don't know why. I tried with function for convertion - private String toUniCode(String strPar)-it successfully shows me the unicode data in alret msg, but it doesn't enters unicode data in SQL Server. In SQL Server only '??????' get entered. I kept data-type in SQL Server as nvarchar to store data in unicode.
    Would it be possible for me, to accept the data as UTF-8 itself & can I store it in SQL Server as it is? How can I do that? I'm accepting data in 'marathi' language.
    Plz, anybody Help me, I'm trying for this from around more than 1 week.
    Thanks in advance for any replies!

    Hello dmorris800,
    Thanx for your help. In fact I've tried lot many alternatives for that. Later I realised that it was problame of Driver, not of code. I was using jdbc:odbc driver which doesn't support unicode, or I don't know what was the problame with it.
    But I downloaded the driver named :'TaveConnect30C'. It is the connection optimised driver of Atinav.com This is the JDBC3 Type 4 Driver for MS SQL Server 6.5/7.0/2000 & trial version of which can be downloaded from http://www.atinav.com/download.htm
    It is really very good type-4 Driver.
    Cheers
    -Yogesh

  • Dealing with the DATE data type in SQL Server

    As you know, a date is stored in SQL Server as "yyyy-mm-dd" when using the DATE data type.  This is also how it displays when I pull it into my Access front-end (even if I set the field's format to Short Date.)
    I'd like to be able to display it based on the user's regional settings.  I know I can use the FORMAT method in VBA to change it to mm/dd/yyyy, but I have users in other countries and I don't want to have to maintain a number of different versions.
    Any idea how I can automatically display the date in my MS Access form based on the user's regional settings?
    Thanks.

    Your solution, however, does not address the root of the problem. Access thinks it is a text field because there is no such thing as a 'Date' data type in Access. You will run into problems anywhere in Access, that you expect it to perform as
    a Date/Time field. E.G. sorting, filtering. 'Date' is one of the newer data types in SQL Server 2008+. You should be using SQL Server DateTime or SmallDateTime data type. Access will recognize those as a Date/Time data type and treat them accordingly.

  • Problem inserting date into MS SQL Server

    I am trying insert date into MS SQL Server database. First I used Statement and when I insert the date only date used to be inserted properly and the time used to be always 12:00:00 AM. I tried PreparedStatement and when I insert I get an error message:
    SQL Error: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented
    I have attached the code.
    GregorianCalendar cal = new GregorianCalendar();
    java.util.Date dtm = (java.util.Date)cal.getTime();
    SimpleDateFormat formatOb = new SimpleDateFormat("dd/MM/yy hh:mm:ss");
    String date= (String)formatOb.format(dtm);
    dateCreated = new java.sql.Date(formatOb.parse(date).getTime());
    PreparedStatement psmt = con.prepareStatement("INSERT INTO Resume (ResumeName, Summary, Skills, OtherInformation, Interests, Memberships, Languages, Category, DateCreated, SupervisorName) VALUES(?,?,?,?,?,?,?,?,?,?)");
    psmt.setString(1, name);
    psmt.setString(2, summary);
    psmt.setString(3, skills);
    psmt.setString(4, info);
    psmt.setString(5, interest);
    psmt.setString(6, member);
    psmt.setString(7, language);
    psmt.setString(8, category);
    psmt.setDate(9, dateCreated);
    psmt.setString(10, loginName);
    psmt.executeUpdate();
    Any suggestions will be really helpful.

    Thanks,
    I changed the field in the database of DateCreated to timestamp, but when I insert the some binary data is inserted into the database. something like 0000000000000017D.
    I installed jtds-0.8.1 driver from source forge. but when try to connect to the database I get an error as:
    Connection refused: connect
    Error: Connection refused: connect
    I have attached the code for setting the driver and url also.
    private String driver = "net.sourceforge.jtds.jdbc.Driver";
    private String url = "jdbc:jtds:sqlserver://TEKKATTE:1433/placement;TDS=7.0";

  • Missing BI Data Tools in SQL Server 2014

    Hi All!
    I just doing the first steps in SSIS 2014 (RTM) after I played around a lot with SSIS 2014 (CTP2).
    In case of CTP2 there was a separate download in MSDN called "SQL Server Data Tools for SQL Server 2014 CTP2" which contained VS2012 + the projects for SSIS, SSRS etc...
    I'm missing these tools for SQL 2014 RTM. What do I do wrong? Could it be, that they are still unreleased?
    Thanks in advance for your help.
    Regards,
    Patrick

    Hi Patrick,
    It's true that the SQL Server Data Tools (SSDT) is not shipped with SQL Server 2014 RTM DVD, and we need to download and install it from:
    Microsoft SQL Server Data Tools - Business Intelligence for Visual Studio 2013
    http://www.microsoft.com/en-us/download/details.aspx?id=42313
    Regards,
    Mike Yin
    TechNet Community Support

  • Which data format accepts MDM server

    Hi All,
                   Which data format accepts MDM server. Suppose when we discuss about XI, It  has own language XML, like that MDM have any own language?
                    And Where the XI helps to MDM consolidation?
    Thanks,
    Satish.

    Hi Satish,
    You can import XML (with or without schema), Excel or Access files into MDM or link directly to other databases (SQL or ODBC).
    You will most likely need XI if you want to automate import processes into MDM. XI has to put the files to be imported into a specified directory so that MDM can pick it up. Also, XI is helpful for some data conversions that MDM can't do.
    Hope this helps,
    Christiane

  • Comments not imported from Data Dictionary of SQL Server. SDDM 3.3.0.747

    Hi,
    SDDM 3.3.0.747 32-bit on Windows 7 64-bit.
    Comments are not imported from Data Dictionary of SQL Server 2008. Connection through Microsoft JDBC Driver 4.0 for SQL Server or jTDS 1.2.7
    What I have tried? In SDDM DDL generation, Comments in DBRMS for SQL Server are generated with "EXEC sp_addextendedproperty 'MS_Description' , 'Test Comment' ..." so I added extended property named "MS_Description" into SQL Server database, both on table and column. None of them were imported from Data Dictionary into SSDM. I have tried both drivers stated above. Is it a bug or am I missing something?
    I've found similar question thread Re: Data dictionary import doesn't import column comments for SDDM 3.0.0.665, so I guess it is a bug when importing with JDBC drivers.
    MiGli
    Edited by: MiGli_1006342 on May 25, 2013 8:32 AM
    Edited by: MiGli_1006342 on May 25, 2013 9:02 AM

    Extended properties were not imported correctly from SQLServer databases at DM 3.3.0.747.
    Calls to sp_addextendedproperty and fn_listextendedproperty have been modified.
    I don't think it is a problem with JDBC drivers.
    A bug fix should be available in the next release of DM.

  • INSERTING DATA INTO A SQL SERVER 2005 TABLE, WHICH HAS A IDENTITY COLUMN

    Hi All,
    I have to insert the data into a SQL SERVER 2005 Database table.
    I am able to insert the data into a normal SQL Server table.
    When I am trying to insert the data into a SQL Server table, which has a identity column (i.e. auto increment column in Oracle) I am getting error saying that can't insert value explicitly when IDENTITY_INSERT is set to OFF.
    Had anybody tried this??
    There are some SRs on this issue, Oracle agreed that it is a bug. I am wondering if there is any workaround from any one of you (refer Insert in MS-SQL database table with IDENTITY COLUMN
    Thanks
    V Kumar

    Even I had raised a SR on this in October 2008. But didn't get any solution for a long time, finally I had removed the identity column from the table. I can't to that now :).
    I am using 10.1.3.3.0 and MS SQL SERVER 2005, They said it is working for MS SQL SERVER TABLE, if the identity column is not a primary key and asked me to refer to note 744735.1.
    I had followed that note, but still it is not working for me.
    But my requirement is it should work for a MS SQL SERVER 2005 table, which has identity column as primary key.
    Thanks
    V Kumar

  • How to replicate data from MS SQL Server  to Oracle

    Hi,
    Can someone please help me on how to replicate data from MS SQL Server to Oracle 8i database.

    Dear,
    I'm a student.
    I do simple replication on Oracle 8.0.5 successfully. (one master site and one snapshot site). I only use the SQL*Plus and Schema Manager to do.
    But when I do advance replication (multimaster replication) I meet many problem. So I don't get the result.
    Do you show me the technology to do that ?
    Thanks !

  • 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+

  • Data transfer from sql server 7.0 to oracle 8i

    iam having problems BIG TIME problems in transferring data from sql server7 to ora8i.
    Can someone plz tell me the steps,procedure to do this or how ican connect to sql server7 and copy all the tables vews etc to ora8i. thanks

    Hi,
    Version 1.2.5.0.0 will be available for free download from this site within the next two weeks.
    I will migrate both schema and data for a SQL Server 7.0 database.
    Please mail [email protected] with your request.
    Regards
    John

Maybe you are looking for