Showing posts with label asp. Show all posts
Showing posts with label asp. Show all posts

Thursday, March 29, 2012

Date range parameters don't work in reportviewer?

Hi, I've got this ssrs 2005 report that works great passing a few
security related parameters from asp.net codebehind. However, there
are two date related parameters that won't be coming from my web form,
but rather from the report form itself. When I test the report's date
parameters from visual studio it work fine, but when I attempt the
same report from a reportviewer no matter what input I place on the
report's date fields or even if I select the date picker, the report
simply resets to default and reloads. And actually the date picker
from the reportviewer does not not even pop up.
Here's my aspx code:
<%@. Page Language="VB" AutoEventWireup="false"
Inherits="_ReportViewer" MasterPageFile="~/Main/MasterPage.master"
CodeFile="~/Reports/CashSales.aspx.vb" Title="Cash Sales" %>
<%@. Register Assembly="Microsoft.ReportViewer.WebForms,
Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content1"
runat="Server">
<rsweb:ReportViewer BackColor="Transparent" ZoomMode="PageWidth"
Width="100%" ProcessingMode="Remote" ID="ReportViewer1"
runat="server">
<ServerReport ReportPath="/Retailer/CashSales"
ReportServerUrl="http://myserver/reportserver" />
</rsweb:ReportViewer>
</asp:Content>
the code behind:
Imports system.web.security.membership
Imports system.web.security.Roles
Imports Microsoft.Reporting.Webforms
Note: I'm only passing the parameters that are not coming from the
reportviewer form.
Partial Class _ReportViewer
Inherits System.Web.UI.Page
Private Users As New Retailer.Core()
Protected Overrides Sub OnLoad(ByVal e As EventArgs)
Dim Roles() As String = GetRolesForUser(Page.User.Identity.Name.ToString)
Dim cred As New Retailer.ReportServerCredentials("myuser",
"mypassword", "mydomain")
ReportViewer1.ServerReport.ReportServerCredentials = cred
Dim param As New ReportParameter("r_user",
Page.User.Identity.Name.ToString)
Dim param2 As New ReportParameter("r_role", Roles(0))
Dim p() As ReportParameter = {param, param2}
ReportViewer1.ServerReport.SetParameters(p)
ReportViewer1.ServerReport.Refresh()
End Sub
End Class
on my reportviewer form, at the top I have parameters for startdate
and end date, they are not set to internal or hidden.
thanks for any help or information.update on this. I see I am getting a javascript error, but it then
loading the report. How can I troubleshoot this? I've got disable i.e
script debugging turned off on i.e 7.0, but where would i place this
javascript to trap the error.
debugger; // execution will break here
to see the errors in VS.NET.
my report viewer in on a contentpage.
I see others have had a similar problem.
thanks for any help or information!|||More on this..
I noticed I get a javascript error when click on the calendar select:
Line: 606
Object Required
When I attempt to debug I get a Just-In-time failed : Unspecified
error. Check the documentation index for 'Just-in-time debugging,
errors' for more information.
and if I enter anything in the date fields, it disregards them and
loads with the defaults.
Could it be that I'm not sending security information when these built
in javascript functions are called?
thanks again.

Tuesday, March 27, 2012

date problems (AGAIN!)

I am trying to use asp to add/edit dates in a sql server db.

I can add a date fine using: -

INSERT INTO news(news_title, news_date, news_intro, news_text)
VALUES('The title of the news',
'25/06/2004',
'This is the introduction to the news article',
'this is the text for the news')

however when i try to update using: -

update news set news_date='23/05/2004' WHERE news_id = 11

I get the following error: -

Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.

the date column is of the datatype datetime
I also have the same problem if i use the same sql directly in query analyzer

Any help HUGELY appreciated, cheers

DanHi,

The way you pass the date format to the SQL should be in mm/dd/yyyy.
Unless you specifially use the Convert Function, you will have to use this in this format. The reason is because there is a default configuration (I dont know where it is :-) ) that takes the date in this format.

HTH
Thanks
Shankar

Sunday, March 25, 2012

Date problem

Hi i finished one website using asp and ms sql server. it using some content management system. i finished the project and tested successfully with my local host, and on a lan server. its all working fine. but when my client hosted it on his system (he have his own hosting) it caused error.

i went through the error and found that following lines are the reson for errors

UPDATE users SET lastlogin = '2005-02-17 07:59:40' WHERE username = 'sreeju'

INSERT INTO my_status (myid, StatusID, datecheckedout, checkedoutby) VALUES (22,1,'2005-02-17 08:05:39','sreeju')

I am getting error message as

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E07)
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

since it is working fine with my server, is there any date settings i need to change in the client sql server...

Please help...
Thanks in Advance...What type is datecheckedout and lastlogin on the server it works on, and the server it does not?|||hi thanks for your care. from the local server i took backup and it restored in my client machine. so i don't know why its happening. so both the server have datatype datetime

Date portion comparison of a datetime field

I have a datetime variable coming from my ASP.NET application that has
a time portion. I give my users the option to perform an equals,
greater than, less than, or between comparison. The trouble comes in
the way the application builds the criteria string. The WHERE clause
passed in is in the format, "(start_dt = '2005/05/16 07:00:00.000')".
What I want to do is only compare the date portion of start_dt to the
date portion of the passed in time. Manipulating the start_dt with the
built-in SQL functions isn't a problem, but altering the date passed in
from the ASP.NET would be a massive framework change in the app.
Is there any way to only compare the date portions of both the SQL
field and the passed in value?
Thanks.Create a stored procedure instead creating the statement dynamically.
create procedure dbo.usp_proc1
@.sd datetime
as
set nocount on
select c1, ..., cn
from table1
where
start_dt >= convert(char(8), @.sd, 112)
and start_dt < convert(char(8), dateadd(day, 1, @.sd), 112)
return @.@.error
go
AMB
"colinhumber" wrote:

> I have a datetime variable coming from my ASP.NET application that has
> a time portion. I give my users the option to perform an equals,
> greater than, less than, or between comparison. The trouble comes in
> the way the application builds the criteria string. The WHERE clause
> passed in is in the format, "(start_dt = '2005/05/16 07:00:00.000')".
> What I want to do is only compare the date portion of start_dt to the
> date portion of the passed in time. Manipulating the start_dt with the
> built-in SQL functions isn't a problem, but altering the date passed in
> from the ASP.NET would be a massive framework change in the app.
> Is there any way to only compare the date portions of both the SQL
> field and the passed in value?
> Thanks.|||You have to convert it to a the valid format you want to comapre it to, e.g.
(from BOL --> Convert)
CONVERT(varchar(8),YourdateinHere,112) which will apply iso date formatting
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"colinhumber" <colinhumber@.discussions.microsoft.com> schrieb im Newsbeitrag
news:AE4EA0BE-51D8-459F-A071-225F6833AFAB@.microsoft.com...
>I have a datetime variable coming from my ASP.NET application that has
> a time portion. I give my users the option to perform an equals,
> greater than, less than, or between comparison. The trouble comes in
> the way the application builds the criteria string. The WHERE clause
> passed in is in the format, "(start_dt = '2005/05/16 07:00:00.000')".
> What I want to do is only compare the date portion of start_dt to the
> date portion of the passed in time. Manipulating the start_dt with the
> built-in SQL functions isn't a problem, but altering the date passed in
> from the ASP.NET would be a massive framework change in the app.
> Is there any way to only compare the date portions of both the SQL
> field and the passed in value?
> Thanks.|||You need to consider using CONVERT fnc with RIGHT
or using DATEPART !
exemple :
right(convert(varchar, @.datetime, 112),10)
or
cast(datepart(hour,@.datetime) as varchar) + ':' +
cast(datepart(minute,@.datetime) as varchar) + ':' +
cast(datepart(second,@.datetime) as varchar)|||Thanks for the quick reply.
Doing the conversion on the start_dt isn't a problem, but as the value being
passed in from the app is in a dynamic string, performing some string
manipulation would be difficult as the string length could vary. The
frameworks as it stands uses dynamic criteria strings so changing that is no
t
an option. I was hoping there was a way to compare only the date portions
without too much manipulation.
"Jens Sü?meyer" wrote:

> You have to convert it to a the valid format you want to comapre it to, e.
g.
> (from BOL --> Convert)
> CONVERT(varchar(8),YourdateinHere,112) which will apply iso date formattin
g
> --
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "colinhumber" <colinhumber@.discussions.microsoft.com> schrieb im Newsbeitr
ag
> news:AE4EA0BE-51D8-459F-A071-225F6833AFAB@.microsoft.com...
>
>|||DateDiff(day, 0, <AnyDate> ) strips off the time portion...
so
Where DateDiff(day, 0, start_dt) <Operator> DateDiff(day, 0, @.PassedInDate)
is one way to do this generically. (Happens to be really fast too.)
"colinhumber" wrote:

> I have a datetime variable coming from my ASP.NET application that has
> a time portion. I give my users the option to perform an equals,
> greater than, less than, or between comparison. The trouble comes in
> the way the application builds the criteria string. The WHERE clause
> passed in is in the format, "(start_dt = '2005/05/16 07:00:00.000')".
> What I want to do is only compare the date portion of start_dt to the
> date portion of the passed in time. Manipulating the start_dt with the
> built-in SQL functions isn't a problem, but altering the date passed in
> from the ASP.NET would be a massive framework change in the app.
> Is there any way to only compare the date portions of both the SQL
> field and the passed in value?
> Thanks.

Monday, March 19, 2012

Date Issue!

I am storing dates in SQL Server 2000 (Using ASP).
The date is getting validated against the Ymd format, by using SET DATEFORMA
T.
In the Enterprise Manager - the date is displayed in local format (dmY).
When i run a store procedure manually it is returned as Ymd.
When i execute stored procedure from asp and load data into a recordset it i
s
displayed in mdY Format.
This is obviously quite confusing. Can anyone give me some insight into what
is happening. How i can retrieve a date in one format (Ymd).Hi
Seems u have to format date using FORMAT Function
renjith
"AJ" wrote:

> I am storing dates in SQL Server 2000 (Using ASP).
> The date is getting validated against the Ymd format, by using SET DATEFOR
MAT.
> In the Enterprise Manager - the date is displayed in local format (dmY).
> When i run a store procedure manually it is returned as Ymd.
> When i execute stored procedure from asp and load data into a recordset it
is
> displayed in mdY Format.
> This is obviously quite confusing. Can anyone give me some insight into wh
at
> is happening. How i can retrieve a date in one format (Ymd).|||I dont know which Function you mean with FORMAT, but here is another option
for that. A good pratice for me is to get the data back in a very common
format and to format it at the client side. The settings the date and time
is formatted depends on some settings concerning the client, the User
connnction to SQL Server (with its special user localized settings) or the
server settings. Perhaps you should read here a little bit further:
http://www.karaszi.com/SQLServer/in...p#OutputFormats
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Renjith" <Renjith@.discussions.microsoft.com> schrieb im Newsbeitrag
news:A2A764AE-4BD0-4B0F-B5FF-A9FF40B6060F@.microsoft.com...
> Hi
> Seems u have to format date using FORMAT Function
> renjith
> "AJ" wrote:
>|||Hi
since AJ is using ASP , there is format function in VB for formatting data
so tht he can give as Format(DateColumn, "Ymd").
Renjith
"Jens Sü?meyer" wrote:

> I don′t know which Function you mean with FORMAT, but here is another opt
ion
> for that. A good pratice for me is to get the data back in a very common
> format and to format it at the client side. The settings the date and time
> is formatted depends on some settings concerning the client, the User
> connnction to SQL Server (with it′s special user localized settings) or t
he
> server settings. Perhaps you should read here a little bit further:
> http://www.karaszi.com/SQLServer/in...p#OutputFormats
> --
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
> "Renjith" <Renjith@.discussions.microsoft.com> schrieb im Newsbeitrag
> news:A2A764AE-4BD0-4B0F-B5FF-A9FF40B6060F@.microsoft.com...
>
>|||OK, that makes sense, i just thought you mean th non-existing function
FORMAT for TSQL
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Renjith" <Renjith@.discussions.microsoft.com> schrieb im Newsbeitrag
news:6F1D14DE-AB4F-4CE9-B7BE-6FDC5C1772EC@.microsoft.com...
> Hi
> since AJ is using ASP , there is format function in VB for formatting data
> so tht he can give as Format(DateColumn, "Ymd").
> Renjith
>
> "Jens Smeyer" wrote:
>|||The regional settings on your computer influence how the date is presented
in Enterprise Manager. So if the regional settings are British Enterprise
Manager will _display_ the dates in dd/mm/yyyy. Query Analyzer isn't
influenced by the regional settings, and will always display dates in
yyyy-mm-dd hh:mm:ss, which is known as the ODBC canonical dateformat.
However, how SQL Server interprets the dateformat of strings depends on the
settings for your login in SQL Server. In Enterprise Manager, look under
<Server>\Security\Logins and look at the Default Language for your username
(or BUILTIN\Administrators if you are a Windows administrator on your local
machine).
To avoid problems with dates as strings, use the formats that are always
interpreted the same by SQL Server independent of any settings:
yyyymmdd and
yyyy-mm-ddThh:mm:ss
Jacco Schalkwijk
SQL Server MVP
"AJ" <AJ@.discussions.microsoft.com> wrote in message
news:FCADD866-6062-4125-9338-4C378973487B@.microsoft.com...
>I am storing dates in SQL Server 2000 (Using ASP).
> The date is getting validated against the Ymd format, by using SET
> DATEFORMAT.
> In the Enterprise Manager - the date is displayed in local format (dmY).
> When i run a store procedure manually it is returned as Ymd.
> When i execute stored procedure from asp and load data into a recordset it
> is
> displayed in mdY Format.
> This is obviously quite confusing. Can anyone give me some insight into
> what
> is happening. How i can retrieve a date in one format (Ymd).|||> Query Analyzer isn't
> influenced by the regional settings
... unless you check Tools, Options, Connections, "Use regional settings wh
en displaying ... dates
and times". :-)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Jacco Schalkwijk" <jacco.please.reply@.to.newsgroups.mvps.org.invalid> wrote
in message
news:eZ5Z1z3XFHA.3040@.TK2MSFTNGP14.phx.gbl...
> The regional settings on your computer influence how the date is presented
> in Enterprise Manager. So if the regional settings are British Enterprise
> Manager will _display_ the dates in dd/mm/yyyy. Query Analyzer isn't
> influenced by the regional settings, and will always display dates in
> yyyy-mm-dd hh:mm:ss, which is known as the ODBC canonical dateformat.
> However, how SQL Server interprets the dateformat of strings depends on th
e
> settings for your login in SQL Server. In Enterprise Manager, look under
> <Server>\Security\Logins and look at the Default Language for your usernam
e
> (or BUILTIN\Administrators if you are a Windows administrator on your loca
l
> machine).
> To avoid problems with dates as strings, use the formats that are always
> interpreted the same by SQL Server independent of any settings:
> yyyymmdd and
> yyyy-mm-ddThh:mm:ss
>
> --
> Jacco Schalkwijk
> SQL Server MVP
>
> "AJ" <AJ@.discussions.microsoft.com> wrote in message
> news:FCADD866-6062-4125-9338-4C378973487B@.microsoft.com...
>|||You need to change the query in all enviornments to use the convert date
standard formats.
select convert(nvarchar,getdate(),101)
Which returns in mm/dd/yyyy format.
05/23/2005
Refer to books online and search for CAST and CONVERT as search criteria and
you will find the list of output standards.
"AJ" wrote:

> I am storing dates in SQL Server 2000 (Using ASP).
> The date is getting validated against the Ymd format, by using SET DATEFOR
MAT.
> In the Enterprise Manager - the date is displayed in local format (dmY).
> When i run a store procedure manually it is returned as Ymd.
> When i execute stored procedure from asp and load data into a recordset it
is
> displayed in mdY Format.
> This is obviously quite confusing. Can anyone give me some insight into wh
at
> is happening. How i can retrieve a date in one format (Ymd).

Date inputs (UK format) in SQL svr 2000 with OLE DB

Hi all,

I'm building an ASP app on a Windows 2000/IIS machine which interfaces
with our SQL Server 2000 database via OLE DB.

Since we're based in the UK I want the users to be able to type in
dates in UK date format to input into the database. In Enterprise
Manager on the SQL Server I can manually enter a record into a table
and just type in a UK date (MM/DD/YYYY e.g. 25/12/2004) and it accepts
it happily.

However, if I enter the exact same record on the form on the web page,
again using the UK date format, I get this back from the IIS box:

HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

Technical Information (for support personnel)

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E07)
The conversion of a char data type to a datetime data type resulted
in an out- of-range datetime value.
/ictest/eventadm.asp, line 78

I'm assuming that despite SQL Server accepting the date in UK format,
OLE DB will not. Can the OLE provider be configured to allow such
date formats, either (I imagine) in the registry or by altering the
connection string?

TIA,
NiallMake sure the SQL Server user is a UK English User otherwise SQL Server will
do this

(presume user language is set to English (American))

This guy is American so he is giving me a date of 25/12/2004. Americans use
MMDDYYYY so what he means is

the 12th day of the 25th month

this as we can guess is way out of range.

Here is another example

SET LANGUAGE us_english
GO

select cast('25/12/2004' as datetime)

Changed language setting to us_english.
Server: Msg 242, Level 16, State 3, Line 2
The conversion of a char data type to a datetime data type resulted in an
out-of-range datetime value.

SET LANGUAGE British
GO

select cast('25/12/2004' as datetime)

2004-12-25 00:00:00.000

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know

"Niall Porter" <niallporter@.yahoo.co.uk> wrote in message
news:2db8d05e.0407280624.773f87ff@.posting.google.c om...
> Hi all,
> I'm building an ASP app on a Windows 2000/IIS machine which interfaces
> with our SQL Server 2000 database via OLE DB.
> Since we're based in the UK I want the users to be able to type in
> dates in UK date format to input into the database. In Enterprise
> Manager on the SQL Server I can manually enter a record into a table
> and just type in a UK date (MM/DD/YYYY e.g. 25/12/2004) and it accepts
> it happily.
> However, if I enter the exact same record on the form on the web page,
> again using the UK date format, I get this back from the IIS box:
>
> HTTP 500.100 - Internal Server Error - ASP error
> Internet Information Services
> Technical Information (for support personnel)
> Error Type:
> Microsoft OLE DB Provider for SQL Server (0x80040E07)
> The conversion of a char data type to a datetime data type resulted
> in an out- of-range datetime value.
> /ictest/eventadm.asp, line 78
> I'm assuming that despite SQL Server accepting the date in UK format,
> OLE DB will not. Can the OLE provider be configured to allow such
> date formats, either (I imagine) in the registry or by altering the
> connection string?
> TIA,
> Niall|||"Niall Porter" <niallporter@.yahoo.co.uk> wrote in message
news:2db8d05e.0407280624.773f87ff@.posting.google.c om...
> Hi all,
> I'm building an ASP app on a Windows 2000/IIS machine which interfaces
> with our SQL Server 2000 database via OLE DB.
> Since we're based in the UK I want the users to be able to type in
> dates in UK date format to input into the database. In Enterprise
> Manager on the SQL Server I can manually enter a record into a table
> and just type in a UK date (MM/DD/YYYY e.g. 25/12/2004) and it accepts
> it happily.
> However, if I enter the exact same record on the form on the web page,
> again using the UK date format, I get this back from the IIS box:
>
> HTTP 500.100 - Internal Server Error - ASP error
> Internet Information Services
> Technical Information (for support personnel)
> Error Type:
> Microsoft OLE DB Provider for SQL Server (0x80040E07)
> The conversion of a char data type to a datetime data type resulted
> in an out- of-range datetime value.
> /ictest/eventadm.asp, line 78
> I'm assuming that despite SQL Server accepting the date in UK format,
> OLE DB will not. Can the OLE provider be configured to allow such
> date formats, either (I imagine) in the registry or by altering the
> connection string?
> TIA,
> Niall

The best way to handle this would probably be to use a date format which
works regardless of any client and server settings - there are two:

'20040728' -- no time needed
'2004-07-28T20:20:00' -- ISO8601, includes time

Although I don't know much about ADO, I believe that if ADO is aware that
the target is a datetime parameter or column, it will automatically handle
the conversion for you. That might be one option for you - pass the value to
a stored procedure, and when you use the Command.CreateParameter method, ADO
will be aware that the parameter is datetime. But I admit that I haven't
tried it myself, so I may be wrong about this.

Simon|||Niall Porter (niallporter@.yahoo.co.uk) writes:
> Since we're based in the UK I want the users to be able to type in
> dates in UK date format to input into the database. In Enterprise
> Manager on the SQL Server I can manually enter a record into a table
> and just type in a UK date (MM/DD/YYYY e.g. 25/12/2004) and it accepts
> it happily.
> However, if I enter the exact same record on the form on the web page,
> again using the UK date format, I get this back from the IIS box:
>
> HTTP 500.100 - Internal Server Error - ASP error
> Internet Information Services
> Technical Information (for support personnel)
> Error Type:
> Microsoft OLE DB Provider for SQL Server (0x80040E07)
> The conversion of a char data type to a datetime data type resulted
> in an out- of-range datetime value.
> /ictest/eventadm.asp, line 78
> I'm assuming that despite SQL Server accepting the date in UK format,
> OLE DB will not. Can the OLE provider be configured to allow such
> date formats, either (I imagine) in the registry or by altering the
> connection string?

So how does your code look like? Since you get the error from OLE DB,
I assume that you are passing the value as a parameter to a prepared
statement, and that you declare the parameter to be of type
adDBTimeStamp. In such case you must use ISO format, 2004-12-25.

If you want to support regional settings, you should use some ASP
routine to convert the date value. CDate() might be your guy, but
we're straying beyond the realms of this newsgroup. You may want to
try an ASP forum.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks for all the help from everyone so far, I'm not quite out of the
woods yet tho!

"Allan Mitchell" <allan@.no-spam.sqldts.com> wrote in message news:<4107c9f7$0$7125$db0fefd9@.news.zen.co.uk>...
> Make sure the SQL Server user is a UK English User otherwise SQL Server will
> do this
> (presume user language is set to English (American))

The database user (a pure SQL Server user) was set to English. I
found another language called "British English", I've changed that
user to British English and now I can input dates in a UK format
(DD/MM/YYYY) which is great, thanks for that. I appreciate the 'best'
way to do it is to use an ISO format but my users wouldn't cope with
such technicalities as this...

However, dates *returned* are still in US format (MM/DD/YYYY)! Is
there some other esoteric setting I have to tweak somewhere?

> This guy is American so he is giving me a date of 25/12/2004. Americans use
> MMDDYYYY so what he means is
> the 12th day of the 25th month
> this as we can guess is way out of range.
>
> Here is another example
> SET LANGUAGE us_english
> GO

Won't that set it for the all databases on the whole server? We have
a number of applications that use the SQL server for their databases,
some of which may well have been developed in the states. If I change
the setting for the whole server, any other applications that don't
use the ISO or other non-regional date formatting will break surely?

> select cast('25/12/2004' as datetime)

Tried this also, didn't make any difference.

> Changed language setting to us_english.
> Server: Msg 242, Level 16, State 3, Line 2
> The conversion of a char data type to a datetime data type resulted in an
> out-of-range datetime value.
> SET LANGUAGE British
> GO
> select cast('25/12/2004' as datetime)
> 2004-12-25 00:00:00.000
> --
> --
> Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
> www.SQLDTS.com - The site for all your DTS needs.
> www.konesans.com - Consultancy from the people who know
>|||Niall Porter (niallporter@.yahoo.co.uk) writes:
> However, dates *returned* are still in US format (MM/DD/YYYY)! Is
> there some other esoteric setting I have to tweak somewhere?

I'm still not sure why you post this in an SQL Server forum, I would
expect this to be an ASP problem. Then again, since you have not posted
any code, I have no idea of what you are doing.

>> SET LANGUAGE us_english
>> GO
> Won't that set it for the all databases on the whole server? We have
> a number of applications that use the SQL server for their databases,
> some of which may well have been developed in the states. If I change
> the setting for the whole server, any other applications that don't
> use the ISO or other non-regional date formatting will break surely?

SET LANGAUGE changes the language for the current session. However, this
option controls how date literals are interpreted on *SQL Server* and
you got the conversion error on client level.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland.

If the client connects as a US user on a UK server entering a data of
'25/12/2004' then wouldn't the error returned be this error. My expereince
of mixing regional settings says it would.

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know

"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns9536ECDAE92D1Yazorman@.127.0.0.1...
> Niall Porter (niallporter@.yahoo.co.uk) writes:
> > However, dates *returned* are still in US format (MM/DD/YYYY)! Is
> > there some other esoteric setting I have to tweak somewhere?
> I'm still not sure why you post this in an SQL Server forum, I would
> expect this to be an ASP problem. Then again, since you have not posted
> any code, I have no idea of what you are doing.
> >> SET LANGUAGE us_english
> >> GO
> > Won't that set it for the all databases on the whole server? We have
> > a number of applications that use the SQL server for their databases,
> > some of which may well have been developed in the states. If I change
> > the setting for the whole server, any other applications that don't
> > use the ISO or other non-regional date formatting will break surely?
> SET LANGAUGE changes the language for the current session. However, this
> option controls how date literals are interpreted on *SQL Server* and
> you got the conversion error on client level.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||Allan Mitchell (allan@.no-spam.sqldts.com) writes:
> If the client connects as a US user on a UK server entering a data of
> '25/12/2004' then wouldn't the error returned be this error. My
> expereince of mixing regional settings says it would.

Depends. The error Neill got was:

Microsoft OLE DB Provider for SQL Server (0x80040E07)
The conversion of a char data type to a datetime data type resulted
in an out-of-range datetime value.

The only way to get that error from Query Analyzer is to connect a linked
server with a date-format conflict along the line.

The problem here is that things can to wrong on several levels. In Neill's
case it got wrong already on client level. I suspect because he was
using adDBTimeStamp to which he must feed an ISO format.

It is also confusing since the regional settings on the client neither the
server on what happens in SQL Server which uses its own language
definitions. You can set language when you connect, but then you have to
pass that in the connection string - and it has to be a language as SQL
Server knows it.

The main problem in Neill's case is that he has not posted any code, so
we are left to guessing.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Date Handling in SQL Server

I have a SQL Database with an ASP front end.
There are actually two webservers which connect to the SQL database in
London.
i have two questions
1. How can I insert null values when inserting dates within my records. If
gives me a type mismatch error.
2. How will the sql server differentiate that the date coming from UK
webserver example "03/01/2005" is 3rd January 2005 and the same date coming
from US webserver "03/01/2005" is 1st March 2005. Do I need to deal with
this in the ASP code?
Thanks in advance for your help.
RegardsHi,
1. Hope you are using the insert this way: insert into dbo.tablename
(test) values (null)
2. I think you have common SQL server for storing data from US and UK.
Actually, I have one question here - where are you trying to
filter/segregate the data on presentation layer or at the database end?
In case of ASP, since you have 2 webservers, client connecting from
respective location should be able to see their dates according to
their regional settings.
Coming back to SQL Server, I don't think wherein SQL Server can handle
both US and UK date formats in the same column, maybe u have to keep a
constraint say check constraint which will check for a column say
country "US" then use US date format or "UK" then use UK date format..
Hope I got you right on your question..
Regards,
Dilip|||The specifying a date in yyyy/mm/dd format should be interpreted the same
for both US and British. For example: 2005/03/01
"JP SIngh" <none@.none.com> wrote in message
news:Oq7pfo0lFHA.3568@.tk2msftngp13.phx.gbl...
>I have a SQL Database with an ASP front end.
> There are actually two webservers which connect to the SQL database in
> London.
> i have two questions
> 1. How can I insert null values when inserting dates within my records. If
> gives me a type mismatch error.
> 2. How will the sql server differentiate that the date coming from UK
> webserver example "03/01/2005" is 3rd January 2005 and the same date
> coming
> from US webserver "03/01/2005" is 1st March 2005. Do I need to deal with
> this in the ASP code?
> Thanks in advance for your help.
> Regards
>|||"JT" <someone@.microsoft.com> wrote in message
news:OGCNx41lFHA.1416@.TK2MSFTNGP09.phx.gbl...
> The specifying a date in yyyy/mm/dd format should be interpreted the same
> for both US and British. For example: 2005/03/01
No - use a format that is understood regardless of any settings.
http://www.karaszi.com/sqlserver/info_datetime.asp

Wednesday, March 7, 2012

date format cannot be saved

Hi guys, I was doing some changes on my asp web pages, I added new field expiry date that will be scanned into the system in format ddmmyyyy but it can't save as i am gettting that message that char can't be converted into datetime as date time was out of range.

I have added this into my asp pages <% Session.LCID = 3081 %> and changed the sql server regional setting setting the date to dd/mm/yyyy I can't set it to ddmmyyyy as there is not option without "/".

Could somebody help me as this is quite frustrating.

ThanksBefore you INSERT the data, change the format. That's fairly easy to do if these are asp pages.

Date Format

I have a written a stored procedure and excecuting it and displaying it in gridview(ASP.NET). I am getting Birthdate in the form of8/23/1956 12:00:00 AM. I just need8/23/1956. I have defined it as smalldatetime in stored procedure. How can I get it in that format ?

HELP.......

In your .net code, if the object is of type DateTime you can call ToShortDate.

|||

Either you can convert the datetime to a varchar in your stored procedure:

select convert(varchar(10), getdate(), 103)

... or you can format the output in the GridView:

<asp:BoundFieldDataField="now"DataFormatString="{0:dd/MM/yyyy}"HtmlEncode="false"/>

|||

Set the DataFormatString, either in designer or HTML:

<asp:BoundField DataField="Date" DataFormatString="{0:dd-MMM-yy}" HeaderText="Date" HtmlEncode="false" />
|||

You can read more about CONVERT here:http://msdn2.microsoft.com/en-us/library/aa226054(SQL.80).aspx

...and more about DataFormatString here:http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx

|||

Thanks a bunch ... millepag

That CONVERT thing worked for me!!!!

Date Format

Im running an ASP.net application on a windows server with SQL server for
the database. The date format I am using is MM/DD/YYYY but that seems to
work on my local server and not on my production server. On my production
server, I get errors if the date isnt in DD/MM/YYYY. Does anyone know why or
where there is a setting to change this? I am not sure if this is a SQL or
server issue
Sounds a little odd. For some reason your default date format sound like UK English.
Have you tried doing direct selects from the SQL sever using the MM/DD/YYYY format.
if that fails then look at sp_configure for the default full-text language. Make sure that it is 1033 for US English and not 2057 for UK English. That may not be the fix but I am still looking.
Jeff

Saturday, February 25, 2012

Date Format

Im running an ASP.net application on a windows server with SQL server for
the database. The date format I am using is MM/DD/YYYY but that seems to
work on my local server and not on my production server. On my production
server, I get errors if the date isnt in DD/MM/YYYY. Does anyone know why or
where there is a setting to change this? I am not sure if this is a SQL or
server issueSounds a little odd. For some reason your default date format sound like UK English
Have you tried doing direct selects from the SQL sever using the MM/DD/YYYY format
if that fails then look at sp_configure for the default full-text language. Make sure that it is 1033 for US English and not 2057 for UK English. That may not be the fix but I am still looking
Jeff

Date Format

Im running an ASP.net application on a windows server with SQL server for
the database. The date format I am using is MM/DD/YYYY but that seems to
work on my local server and not on my production server. On my production
server, I get errors if the date isnt in DD/MM/YYYY. Does anyone know why or
where there is a setting to change this? I am not sure if this is a SQL or
server issueSounds a little odd. For some reason your default date format sound like UK
English.
Have you tried doing direct selects from the SQL sever using the MM/DD/YYYY
format.
if that fails then look at sp_configure for the default full-text language.
Make sure that it is 1033 for US English and not 2057 for UK English. That
may not be the fix but I am still looking.
Jeff

Tuesday, February 14, 2012

DATE AND HOUR

Hello people,

I'm migrating an application from asp to asp.net and access to ms sql 2005. On the old db, there's a table with a column to store date and a column to store time. Ms sql only works with date and time together, right? I created a query to get the time from time column and update the date column inserting the time. I did something like this:

UPDATE S_ACC_MONEY
SET Date_Oper = CONVERT(varchar, Date_Oper, 101) + ' ' + CONVERT(varchar, Time_Oper, 108)

Does anyone knows a better way to do that? Any other comments?

Thanks!

you might also want to do a final conversion to datetime as in:

Date_Oper =CONVERT(datetime,CONVERT(varchar, Date_Oper, 101) + ' ' + CONVERT(varchar, Time_Oper, 108))