how to convert 2010-10-10 to numeric or int datatype ?
View Complete Post
HiIm receiving a strange error Error Message: Conversion from string "15/08/2010 22:21:35" to type 'Date' is not valid.I know this is generally down to cultural date formats etc, however the reason this is strange is it just randomly occured twice in the last week, the website has been running since october and nothing has changed,The error constantly occured until the IIS was reset and recompilled the site, its been running fine since, however im just trying to figure out what could cause such an error to occur.I've narrowed it down to a line of code which is:bktime = DReader.Item("Bktime").ToStringbktime = Year(CDate(bktime)) & "-" & fmt(Month(CDate(bktime)), 2) & "-" & fmt(Day(CDate(bktime)), 2)
Has anyone else encountered this randomly occuring and is there anything i can put in place to prevent this in future?CheersMike
I am getting the below error. Please see my code below and let me know what is wrong.
dim sDatetime as string = startdate & " " &starttime & "AM"
dim dt as Date = CDate(sDatetime)
I am getting the Conversion from string "09/28/10 9.00AM" to type 'Date' is not valid error in this line.
select [RowID]=ROW_NUMBER() over (order by b.userid),b.userid [Data Capturer's],
COUNT(distinct(g.boxnumber)) [Count] from box b join General_SAM g
on (g.BoxNumber=b.boxnumber) where b.code=5000 and b.department=02 and b.origindate
between '2010-07-28 00:00:00.000' and '2010-09-28 00:00:00.000' group by b.userid
My computer is set to UK - dd-mm-yyyy.
Is there a way that i can supply date using the above format i.e. dd-mm-yyyy
I am working with a classic ASP application that we are trying to keep hobbling along while it gets rewritten. The underlying database has been upgraded many times and is currently running on SQL Server 2008.
Recently a column of table was updated from a smalldatetime (with a check constraint to ensure it didn't have any time values) to simply the date type, but the code now does not work. I was originally using SQLOLEDB, and was confident that treating
the date as a string would be find with our client. Unfortunately it does not, nor does it work using the SQLNCLI10 client.
This is the stripped down code:
Set adoConnection = aspServer.CreateObject("ADODB.Connection")
adoConnection.Open "Provider=SQLNCLI10" ' Details Removed
Set adoRS = aspServer.CreateObject("ADODB.Recordset")
adoRS.CursorLocation = adUseClient
adoRS.Open "SELECT * FROM TestTable WHERE id = 0", adoConnection, adOpenKeyset, adLockOptimistic, adCmdText
adoRS("datecolumn") = "09/20/2010"
On the update line, I get the following error:
Microsoft SQL Server Native Client 10.0
Input Date : 4/08/2010 6:27:00 AM
DATA TYPE : STRING
Output Required: 2010/08/04
Expression used : SUBSTRING(@[User::ExtractionDate],1,FINDSTRING(@[User::ExtractionDate],"/",1) - 1) + "-" + SUBSTRING(@[User::ExtractionDate],FINDSTRING(@[User::ExtractionDate],"/",1) + 1,2) + "-" + SUBSTRING(@[User::ExtractionDate],FINDSTRING(@[User::ExtractionDate],"/",2)
Current Date is getting: 4-08-2010
URGENT HELP GUYS I NEED THE OUTPUT IN THIS FORMAT
Msg 241, Level 16, State 1, Line 8
Conversion failed when converting date and/or time from character string.
declare @itemID varchar(20)
declare @startdt varchar(12)
declare @enddt varchar(12)
set @itemID = ''
I am having badly stuck!!I have spent hours in trying to solve that.
I am having the following loving function:
Public Function InsertDeleteUpdate(ByVal command As String) As Boolean
cmd.Connection = objectconnection
cmd.CommandText = command
Catch ex As Exception
In the above function I pass the following string:
gridcost = Convert.ToDecimal(txtcost.Text)
_date = Convert.ToDateTime(txtdatefrom.Text)
patient = Convert.ToInt32(ddlpatients.SelectedValue)
sqlstring = "execute dbo.InsertDeleteUpdate " & patient & ",'" & _date + "'," & gridcost & ",'" & txtinsurances.Text & "','" & checkreceipt.Checked + "'," & appointment_xidInsertDeleteUpdate(sqlstring)
The string includes a stored procedure.The store procedure includes the following parameters: