Re: Getting the correct date format from SQL-Server 2000




"PB" <PB@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:594B7957-7EF8-45B6-97F2-1E2B56262357@xxxxxxxxxxxxxxxx
>I have an ASP web page that causes an out of process dll to execute and
> connect to an SQL server database to retrieve records. No matter what I
> try,
> the date fields are always returned as dd/mm/yyyy.
>
> How do I get the vbasic dll program to return yyyy/mm/dd format dates from
> the SQL Server?
>
> I've tried
> 1) Executing the SET DATEFORMAT ymd SQL command after openning the
> connection
> 2) Setting the regional Date format on the userid the out of process dll
> executes under.
>
> What else is there. It works properly on one server but not another.

SET DATEFORMAT only affects interpretation of input. I was thinking
collation might affect it, but from a glance at the BOL it doesn't look like
it. You might try setting the regional format for the user context under
which SQL Server runs, if that's practical.

The most certain way to make sure dates are rendered as expected every time
is to derive a column using the CONVERT() built-in function:

SELECT CONVERT(varchar(10), [mydate], 120) As [mydate] FROM [mytable]

The magic number 120, and friends can be found in the BOL under the topic
"Cast and Convert". Limiting the width to 10 truncates the time component.


HtH,
Mark



> Running
> W2000 Server
> SQL Server 2000
> VB 6.0


.



Relevant Pages

  • Re: Execute Persmission denied on object sp_OACreate
    ... > SQL Server is creating a job behind the scenes. ... > permissions. ... > SA account password and gaining access to the database. ... >>> How can get a user permissions to execute these stored procedures ...
    (microsoft.public.sqlserver.security)
  • Re: SSIS - OLE DB Command - how to retrieve query results ???
    ... my side according to your process, and I managed to execute the task. ... Data Destination: <My SQL Server 2005 Instance>.TestDB ... OLE DB Command: ...
    (microsoft.public.sqlserver.dts)
  • Re: 3 Simple Security SQL Statements
    ... Kalen Delaney, SQL Server MVP ... window and execute. ... Builds a list of text commands. ... EXEC sp_addrolemember 'WebUsersRole', 'WebUser' ...
    (microsoft.public.sqlserver.security)
  • Re: DTS Error EXCEPTION_ACCESS_VIOLATION
    ... >>We have some DTS jobs that runs every night called via a ... >>Package ... If this is no help, then please describe how you execute the package, ... DTS - http://www.sqldts.com PASS - the definitive, global community for SQL Server professionals ...
    (microsoft.public.sqlserver.dts)
  • Re: Problem with the Legacy ASP files and the Sql Server Express
    ... It looks like it is not going to be an easy job getting it to work on the SQL Server 2005 and Express:(. ... 'Then you can execute the command and then retrieve the ID ... I am 100% sure this code works against any version of SQL Server, as long as the connection is OK and the SP has two parameters @varCompany as Input and @Return_Value as Output. ... I do not think your problem is due to difference of SQL Server2000 and SQL Server2005, unless your stored procedure has some thing that only works in SQL Server2000, not SQL Server 2005. ...
    (microsoft.public.dotnet.framework.aspnet)