Problem Converting Smalldatetime To 12hr Time Value

Mar 9, 2007

Hi,

I have two smalldatetime fields starttime and endtime

I want to display them like

select convert(varchar,starttime,108) + ' to ' + convert(varchar,endtime,108) from tbTest

the data in the field is

starttime endtime

1/3/2006 9:00:00 1/3/2006 6:00:00



the result I am getting is

09:00:00 to 18:00:00

Where as I want it something like this

9.00 AM to 6.00 PM

Is it possible? what query should be used for this?

View 5 Replies


ADVERTISEMENT

Trouble Converting Smalldatetime Column

Aug 21, 2007

I have a data field that's datatype int and I need to convert it to smalldatetime, however, I get one row erroring out due to a typo in the data that has a date of 21190101. What's wrong with my case statement to set that one typo to 20790101?

'SD' = Case When pro_date > 20790000 Then
pro_date = '20790101'
Else CAST(CAST(pro_date AS VARCHAR) AS SMALLDATETIME) End,

View 4 Replies View Related

Conversion Failed When Converting Character String To Smalldatetime Data Type

Oct 12, 2006

I am newbie in asp and sql, and I am using VS & SQL expresswhen I try to submit I get following error"Conversion failed when converting character string to smalldatetime data type"Following is my insert statement<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:oncallConnectionString %>"SelectCommand="SELECT data.* FROM data" InsertCommand="INSERT INTO data(Apps, Location, Impact, System, Date, Start_Time, End_Time, Duration, Problem, Cause, Solution, Case, Comments) VALUES ('@DropDownList1','@DropDownList2','@DropDownList3','@TextBox6','@DropDownCalendar1','@DropDownCalendar2','@DropDownCalendar3','@TextBox1','@TextBox2','@TextBox3','@TextBox4','@TextBox5','@TextBox7')"></asp:SqlDataSource>These are @DropDownCalendar1','@DropDownCalendar2','@DropDownCalendar3' defined as datetime in database.I would appriciate if somebody could help.

View 7 Replies View Related

Conversion Failed When Converting Character String To Smalldatetime Data Type.

Mar 25, 2007

Hello, I have problem with this code.(This program presents - there is GridView tied to a SQL database that will sort the data selected by a dropdownList at time categories. There are  2  time categories in DropDownList - this day, this week.
 Problem: when I choose one categorie in dropDownlist for examle this week and submit data on the server I got this error.
Conversion failed when converting character string to smalldatetime data type.
Here is code:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
 
 
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
 
string datePatt = @"yyyymmdd";
// Get start and end of day
DateTime StartDate = DateTime.Today;
 
string @StartDate1 = StartDate.ToString(datePatt);
 
string @EndDate = StartDate.AddDays(1).ToString(datePatt);
// Get start and end of week
string @startOfWeek = StartDate.AddDays(0 - (int)StartDate.DayOfWeek).ToString(datePatt);
string @startOfNextWeek = StartDate.AddDays(7 - (int)StartDate.DayOfWeek).ToString(datePatt);
 
 
switch (DropDownList1.SelectedValue)
{
 
case "1":
// day
SqlDataSource1.SelectCommand = "SELECT [RC_USER_ID], [DATE], [TYPE] FROM [T_RC_IN_OUT]" + "WHERE" + "[DATE] >=" + "'@StartDate1'" + " AND [DATE] < " + "'@EndDate'";
break;
case "2":
//week
SqlDataSource1.SelectCommand = "SELECT [RC_USER_ID], [DATE], [TYPE] FROM [T_RC_IN_OUT]" + "WHERE" + "[DATE] >=" + "'@startOfWeek'" + "AND [DATE] <" + "'@startOfNextWeek'";
break;
 
}
 
}
 
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<style type="text/css">
body {
font: 1em Verdana;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
&nbsp;&nbsp;
 
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
Style="z-index: 100; left: 414px; position: absolute; top: 22px">
<asp:ListItem Selected="True" Value="1">jeden den</asp:ListItem>
<asp:ListItem Value="2">jeden tyden</asp:ListItem>
</asp:DropDownList>
 
<asp:GridView ID="GridView1" runat="server" Style="z-index: 102; left: 228px; position: absolute;
top: 107px" DataSourceID="SqlDataSource1" AutoGenerateColumns="True">
 
</asp:GridView>
&nbsp; &nbsp;<br/> <br/>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=CRSQLEXPRESS;
Initial Catalog=MyConn;Integrated Security=True"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
 

View 4 Replies View Related

Conversion Failed When Converting Character String To Smalldatetime Data Type

Oct 3, 2007

I am running the following query:
 select distinct hqvend, hqvprd,fprod,idesc,ilead,sum(cast(fqty as int) )as fqty, (cast(hqvend as varchar(5))+'/'+ltrim(rtrim(fprod))+'/'+cast(ilead as varchar(3))) as Keydata,'L1/'+rtrim(fprod) as LocPartno from tblkfpl01 inner join hqtl01 on (fprod=hqprod) inner join iiml01 on (hqvend=ivend and hqprod=iprod) where  cast(cast(hqeff as varchar(8)) as smalldatetime) <= (Select CONVERT(varchar(8), getdate(), 1)) and  cast(HQDIS as varchar(8)) >= (Select CONVERT(varchar(8), getdate(), 1))  and hqvend like '134%' group by hqvend,fprod,hqvprd,idesc,ilead   order by hqvend,fprod
The bold sections are giving me the error message. The query works as written above, butis only evaluating on one date, contained in hqeff. However, when I try to modify the second date, HQDIS, by casting it the same way as the one before it:
 select distinct hqvend, hqvprd,fprod,idesc,ilead,sum(cast(fqty as int) )as fqty, (cast(hqvend as varchar(5))+'/'+ltrim(rtrim(fprod))+'/'+cast(ilead as varchar(3))) as Keydata,'L1/'+rtrim(fprod) as LocPartno from tblkfpl01 inner join hqtl01 on (fprod=hqprod) inner join iiml01 on (hqvend=ivend and hqprod=iprod) where  cast(cast(hqeff as varchar(8)) as smalldatetime) <= (Select CONVERT(varchar(8), getdate(), 1)) and  cast(cast(HQDIS as varchar(8)) as smalldatetime) >= (Select CONVERT(varchar(8), getdate(), 1))  and hqvend like '134%' group by hqvend,fprod,hqvprd,idesc,ilead   order by hqvend,fprod
I get the error message. I need to select based on both dates (hqeff AND HQDIS), but cannot seem to be able to it.... Both fields are of type Dedimal, with a length of 8, and dates stored in them look like: 20071003 (YYYYMMDD).
Any suggestions?

View 2 Replies View Related

Syntax Error Converting Character String To Smalldatetime Data Type.

Aug 8, 2005

Hi guys and gals,I have the following code:CREATE PROCEDURE searchRecords(     @searchFor  NVarchar (25)  = NULL,     @fromDate  NVarchar (25)  = NULL,     @toDate  NVarchar (25)  = NULL)
AS
IF @fromDate IS NOT NULL     DECLARE @fromDateString VarChar(200)     SET @fromDateString = '  CONVERT(smalldatetime, ''' + @fromDate + ''') '
IF @toDate IS NOT NULL     DECLARE @toDateString VarChar(200)     SET @toDateString = '  CONVERT(smalldatetime, ''' + @toDate + ''') '
SELECT * FROM MIPR WHERE      ID = @searchFor      OR DESC_QTY = @searchFor      OR REQ_ACTIVITY = @searchFor      OR ACC_ACTIVITY = @searchFor      OR MANYEARS = @searchFor      OR TECH_POC = @searchFor      OR RESOURCE_POC = @searchFor      OR SI_DATE BETWEEN @fromDateString   AND  @toDateString;GOit creates an error that I can't seem to fix. the error I get is:Syntax error converting character string to smalldatetime data type.How can I fix this? Thanks in advance!

View 1 Replies View Related

Conversion Failed When Converting Character String To Smalldatetime Data Type

Oct 21, 2007

Hi,

I have SQL Server 2005 database table with the following data definition as follows:

ID int
LST_TIME varchar(5)
LST_DATE varchar(21)
LST_WEEK int
SUBJECT varchar(100)


Date format (Month,day YEAR) eg.- October, 21 2007
Time format, 00 - 23 hours, HH:MM eg. - 18:58

, and a VB code as below:

Dim Command As New SqlClient.SqlCommand("SELECT * FROM dbo.LISTS WHERE (LST_WK = DATEPART(wk, GETDATE())) AND (CONVERT(datetime, LST_DATE) = CONVERT(datetime, CONVERT(varchar, GETDATE(), 110)))
AND(CONVERT(smalldatetime, LST_TIME) = CONVERT(smalldatetime, CONVERT(varchar(5), GETDATE(), 108)))", conn)

Dim dataReader As SqlClient.SqlDataReader = Command.ExecuteReader(CommandBehavior.CloseConnection)
While dataReader.Read()

Dim NewAlert As New Alert(dataReader("SUBJECT").ToString(), DateTime.Parse(dataReader("LST_DATE").ToString(),
DateTime.Parse(dataReader("LST_TIME").ToString())))

:
:
:
I am encountering error: System.Data.SqlClient.SqlException: Conversion failed when converting character string to smalldatetime data type, which points to the codes in bold. Just wondering anyone out there has got a solution to my problem. Thank you.

View 5 Replies View Related

Conversion Failed When Converting Character String To Smalldatetime Data Type

Apr 10, 2008

Recently i traspased a database from sql server 2000 in spanish to sql server 2005 in english. I change the language of the user sa to spanish and the database is in spanish. . The problem is our dateformat is dmy, i try to force with set dateformat dmy, but always i execute a stored procedure that have a date as input it fail. The error is:

Msg 295, Level 16, State 3, Procedure pa_CalendarioGestion, Line 40
Conversion failed when converting character string to smalldatetime data type.

The code of stored procedure in this line is:

set @diaActual = dateadd("d", @i, @fechaInicio)

This stored procedure in sql server 2000 in spanish not have any problems. For this reason i think the problem is in the configuration.

I hope someone can help me. Thanks.

View 10 Replies View Related

Conversion Failed When Converting Character String To Smalldatetime Data Type

Oct 10, 2006

I am newbie in asp and sql, and I am using VS & SQL express

when I try to submit I get following error

"Conversion failed when converting character string to smalldatetime data type"

Following is my insert statement

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:oncallConnectionString %>"

SelectCommand="SELECT data.* FROM data" InsertCommand="INSERT INTO data(Apps, Location, Impact, System, Date, Start_Time, End_Time, Duration, Problem, Cause, Solution, Case, Comments) VALUES ('@DropDownList1','@DropDownList2','@DropDownList3','@TextBox6','@DropDownCalendar1','@DropDownCalendar2','@DropDownCalendar3','@TextBox1','@TextBox2','@TextBox3','@TextBox4','@TextBox5','@TextBox7')">

</asp:SqlDataSource>

These are @DropDownCalendar1','@DropDownCalendar2','@DropDownCalendar3' defined as datetime in database.

I would appriciate if somebody could help.

Thanks

View 3 Replies View Related

How To Get Time In SmallDateTime?

Oct 13, 2005

Hi,

I just want to get the value from a smalldatetime into time only in a SQL Statement

10/10/2005 10:00:00 AM --- > 10:00:00 AM

What would be the best approached?


Thanks,
Vince

View 1 Replies View Related

Time Part Of Smalldatetime Field

Nov 14, 2001

I'm trying to extract the time part of a smalldatetime field in a usprocedure to return just the time. I've used Datepart() to get the hours or minutes but you can't get both without getting messy. Anyone know a way to keep it neat & simple?

Thanks, archie

View 2 Replies View Related

Updating Time Of Smalldatetime Field

Apr 19, 2007

How does one update the time part of a smalldatetime field...?
2006-11-16 20:12:00 ---> 2006-11-16 16:30:00
2005-06-01 18:19:00 ---> 2005-06-01 16:30:00

I have tried using the datepart but I'm doing something incorrectly.

thanks,

Jonathan

View 7 Replies View Related

Drop The Time Portion Of A Smalldatetime Field

Jul 20, 2005

In VBA I'd use Format(myDateField,"Short Date") to display 1/31/2004instead of 1/31/2004 10:30:25 AMHow can I do this in a stored procedure?lq

View 2 Replies View Related

Transact SQL :: Converting 24hrs Time To 12 Hours Time Query Format?

Apr 21, 2015

SELECT 
    CONVERT(VARCHAR(10),attnc_chkin_dt,101) as INDATE,
    CONVERT(VARCHAR(10),attnc_chkin_dt,108) as TimePart
FROM pmt_attendance

o/p
indate   04/18/2015
time part :17:45:00

I need to convert this 17:45:00 to 12 hours date format...

View 8 Replies View Related

SQL 2012 :: Converting Time String In Temp Table To Military Time Then Cast As Integer?

Dec 26, 2014

I need to take a temporary table that has various times stored in a text field (4:30 pm, 11:00 am, 5:30 pm, etc.), convert it to miltary time then cast it as an integer with an update statement kind of like:

Update myTable set MovieTime = REPLACE(CONVERT(CHAR(5),GETDATE(),108), ':', '')

how this can be done while my temp table is in session?

View 2 Replies View Related

Stored Proc Error: Error Converting Character String To Smalldatetime Data Type

Feb 12, 2005

I am trying to create a page that adds users to a MS SQL database. In doing so, I have run into a couple errors that I can't seem to get past. I am hoping that I could get some assistance with them.

Error from SQL Debug:
---
Server: Msg 295, Level 16, State 3, Procedure AdminAddUser, Line 65
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting character string to smalldatetime data type.
---

Error from page execution:
---
Exception Details: System.Data.OleDb.OleDbException: Error converting data type varchar to numeric.

Source Error:

Line 77: cmd.Parameters.Add( "@zip", OleDbType.VarChar, 100 ).Value = Request.Form("userZip")
Line 78:
Line 79: cmd.ExecuteNonQuery()
---


Below is what I currently have for my stored procedure and the pertinent code from the page itself.

Stored Procedure:
---
CREATE PROCEDURE dbo.AdminAddUser( @username varchar(100),
@password varchar(100),
@email varchar(100),
@acct_type varchar(100),
@realname varchar(100),
@billname varchar(100),
@addr1 varchar(100),
@addr2 varchar(100),
@city varchar(100),
@state varchar(100),
@country varchar(100),
@zip varchar(100),
@memo varchar(100) )
AS
BEGIN TRAN

--
-- Returns 1 if successful
-- 2 if username already exists
-- 0 if there was an error adding the user
--

SET NOCOUNT ON
DECLARE @error int, @rowcount int

--
-- Make sure that there isn't already a user with this username
--

SELECT userID
FROM users
WHERE username=@username

SELECT @error = @@ERROR, @rowcount = @@ROWCOUNT

IF @error <> 0 OR @rowcount > 0 BEGIN
ROLLBACK TRAN
RETURN 2
END

--
-- Set expiration date
--

DECLARE @expDate AS smalldatetime

IF @acct_type = "new_1yr" BEGIN
SET @expDate = DATEADD( yyyy, 1, GETDATE() )
END

IF @acct_type = "new_life" BEGIN
SET @expDate = DATEADD( yyyy, 40, GETDATE() )
END

DECLARE @paidCopies AS decimal
SET @paidCopies = 5


--
-- Add this user to the database
--

IF @acct_type <> "new" BEGIN

INSERT INTO users (userName, userPassword, userEmail, userJoinDate,
userPaidCopies, userExpirationDate, userLastPaidDate,
userBname, userRealName, userAddr1, userAddr2, userCity,
userState, userCountry, userZip, userMemo )
VALUES (@username, @password, @email, GETDATE(), @realname, @billname,
@paidCopies, @expDate, GETDATE(), @addr1, @addr2, @city, @state, @country, @zip, @memo )

SELECT @error = @@ERROR, @rowcount = @@ROWCOUNT

IF @error <> 0 OR @rowcount < 1 BEGIN
ROLLBACK TRAN
RETURN 0
END

END

IF @acct_type = "new" BEGIN

INSERT INTO users (userName, userPassword, userEmail, userJoinDate,
userBname, userRealName, userAddr1, userAddr2, userCity,
userState, userCountry, userZip, userMemo )
VALUES (@username, @password, @email, GETDATE(), @realname, @billname,
@addr1, @addr2, @city, @state, @country, @zip, @memo )

SELECT @error = @@ERROR, @rowcount = @@ROWCOUNT

IF @error <> 0 OR @rowcount < 1 BEGIN
ROLLBACK TRAN
RETURN 0
END

END



COMMIT TRAN
RETURN 1
GO
---


Page Code:
---
Sub AddUser(Sender as Object, e as EventArgs)

Dim db_conn_str As String
Dim db_conn As OleDbConnection
Dim resultAs Int32
Dim cmdAs OleDbCommand


db_conn_str = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=xxxxx; User ID=xxxxx; PWD=xxxxx;"
db_conn = New OleDbConnection( db_conn_str )
db_conn.Open()

cmd = new OleDbCommand( "AdminAddUser", db_conn )
cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add( "result", OleDbType.Integer ).Direction = ParameterDirection.ReturnValue

cmd.Parameters.Add( "@username", OleDbType.VarChar, 100 ).Value = Request.Form("userName")
cmd.Parameters.Add( "@password", OleDbType.VarChar, 100 ).Value = Request.Form("userPass")
cmd.Parameters.Add( "@email", OleDbType.VarChar, 100 ).Value = Request.Form("userEmail")
cmd.Parameters.Add( "@acct_type", OleDbType.VarChar, 100 ).Value = Request.Form("userEmail")
cmd.Parameters.Add( "@realname", OleDbType.VarChar, 100 ).Value = Request.Form("userRealName")
cmd.Parameters.Add( "@billname", OleDbType.VarChar, 100 ).Value = Request.Form("userBname")
cmd.Parameters.Add( "@addr1", OleDbType.VarChar, 100 ).Value = Request.Form("userAddr1")
cmd.Parameters.Add( "@addr2", OleDbType.VarChar, 100 ).Value = Request.Form("userAddr2")
cmd.Parameters.Add( "@city", OleDbType.VarChar, 100 ).Value = Request.Form("userCity")
cmd.Parameters.Add( "@state", OleDbType.VarChar, 100 ).Value = Request.Form("userState")
cmd.Parameters.Add( "@country", OleDbType.VarChar, 100 ).Value = Request.Form("userCountry")
cmd.Parameters.Add( "@memo", OleDbType.VarChar, 100 ).Value = Request.Form("userMemo")
cmd.Parameters.Add( "@zip", OleDbType.VarChar, 100 ).Value = Request.Form("userZip")

cmd.ExecuteNonQuery()

(...)

---

View 1 Replies View Related

Converting US Time To IST

Nov 28, 2007

Do we have any function that will convert US time(as in the database) to IST in the select query.

View 1 Replies View Related

Converting SQL Internal Time

May 30, 2000

I am trying to create custom reports with Access by linking to SQL tables in the SMS 2.0 software metering database. The only problem that I am having is trying to convert the internal SQL time/date nine digit format for when programs started or ended to a standard format. Is there a special function within either SQL or Access that will do this? Thanks.

View 2 Replies View Related

Please Help! Converting From Unix Time

Nov 1, 1999

I have a date field from a Unix machine (ex. 917478174). I need to convert this date to 1/1/1999.

Any help?

Thanks!

-aw

View 1 Replies View Related

Converting Time Format

Jun 14, 2007

Dear all,

i have one table that colum is
164020 ---- that on convert into hh:mm:ss like 16:40:20

advance thanks

View 2 Replies View Related

HELP HELP Converting Date Time

May 30, 2002

I have a table that has a nvarchar field of (12) I need to convert this to a smalldatetimefield.

I get the following message

Error Source: Microsoft Data Transformation Services (DTS) Data Pump
Error Description:Insert error, column 1 ('timeid', DBTYPE_DBTIMESTAMP), status 6: Data overflow.
Error Help File:sqldts80.hlp
Error Help Context ID:30702


Can someone please tell me how to convert this field without getting this message?????

Thanks,
Dianne

View 4 Replies View Related

Converting Decimal To Time

Nov 18, 2005

how do you convert a numeric to time format if it shows hours but a decimal figure for Minutes. For example if I have hours in decimal format like this

28.5000

but I want to show it in this format:

28:30:00

where 28 = hours, 30 = minutes, 00 = seconds

Thanks.

View 4 Replies View Related

Converting Decimal Time To HH:MM

Apr 28, 2008

In Reporting Services, I have a decimal time field (18,2) in my report which I wish to display as HH:MM. Similarly, I req a sum of total hours and minutes as a summary. Whats the expression for doing this. I've googled far and wide and cannot find a definitve solution.

Thanks.

View 2 Replies View Related

Converting Decimal Value To Time

Mar 3, 2008

I have a field that currently is displaying time in decimal form. I would like to convert it to time format. For example: when it displays 6.46 I would like it to be converted to 00:06:27. Can I do this within reporting services?

View 8 Replies View Related

Error Converting Date Time

Apr 26, 2004

Hi i m tring to convert a date time

declare @a datetime
declare @b varchar(10)
set @b='26/04/2004'
set @a= Convert(datetime, @b)

but it gives me this error:

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


I believe is my date format..i want to know how to make sure that i am the dd/mm/yyyy format is correct way?

View 3 Replies View Related

Slow Response Time After Converting DB From SQL 6.5 To 7.0

Feb 10, 2000

We did an in place convertion of our data base from MS SQL Server 6.5 to 7.0.
Our application is much slower now on SQL 7.0. Any idea why?
The following is a sample SQL statement that runs quickly on SQL 6.5 and takes a long time on SQL 7.0 I also attached the query plans from SQL 6.5 and 7.0.




SELECT Person_Name.PerNam_Person_Name_PK ,
Person_Name.PerNam_Row_Status ,
Person_Name.PerNam_Last_Name_Sndx ,
Person_Name.PerNam_Last_Name ,
Person_Name.PerNam_Name_Suffix ,
Person_Name.PerNam_First_Name ,
Person_Name.PerNam_Name_Prefix ,
Person_Name.PerNam_Middle_Name ,
Person_Name.PerNam_Event_Person_FK ,
Event.Evn_Event_Nbr ,
Event.Evn_Event_Type ,
Event_Person.EvnPer_Last_Name ,
Event_Person.EvnPer_First_Name ,
Event_Person.EvnPer_Middle_Name ,
Event_Person.EvnPer_Name_Prefix ,
Event_Person.EvnPer_Name_Suffix
FROM Person_Name , Event , Event_Person
WHERE (Person_Name.PerNam_Agency_ID = "CL")
AND ( Person_Name.PerNam_Event_Person_FK = Event_Person.EvnPer_Event_Person_PK )
and ( Event_Person.EvnPer_Event_FK = Event.Evn_Event_PK )
and (Person_Name.PerNam_Person_Name_PK = 0 or ( Person_Name.PerNam_Event_Person_FK = 581541) )
and ( Person_Name.PerNam_Row_Status <> "D" )




Query plan in SQL 6.5

SQL Server Execution Times:
cpu time = 0 ms. elapsed time = 31250 ms.
STEP 1
The type of query is INSERT
The update mode is direct
Worktable created for REFORMATTING
FROM TABLE
Person_Name
Nested iteration
Index : PK_Person_Name
FROM TABLE
Person_Name
Nested iteration
Index : PerNam_Event_Person_FK
FROM TABLE
Person_Name
Nested iteration
Using Dynamic Index
FROM TABLE
Event_Person
Nested iteration
Index : PK_Event_Person
TO TABLE
Worktable 1
STEP 2
The type of query is SELECT
FROM TABLE
Worktable 1
Nested iteration
Table Scan
FROM TABLE
Event
Nested iteration
Index : PK_Event
SQL Server Parse and Compile Time:
cpu time = 0 ms.
Table: Person_Name scan count 2, logical reads: 6, physical reads: 5, read ahead reads: 0
Table: Event scan count 0, logical reads: 0, physical reads: 0, read ahead reads: 0
Table: Event_Person scan count 0, logical reads: 0, physical reads: 0, read ahead reads: 0
Table: Worktable scan count 0, logical reads: 0, physical reads: 0, read ahead reads: 0
Table: Worktable scan count 1, logical reads: 1, physical reads: 0, read ahead reads: 0

SQL Server Execution Times:
cpu time = 0 ms. elapsed time = 62 ms.



Query plan on SQL 7.0

SQL Server parse and compile time:
CPU time = 431 ms, elapsed time = 535 ms.
.................
Table 'Event'. Scan count 1, logical reads 3, physical reads 3, read-ahead reads 0.
Table 'Event_Person'. Scan count 1, logical reads 6, physical reads 5, read-ahead reads 0.
Table 'Person_Name'. Scan count 1, logical reads 4588, physical reads 2, read-ahead reads 4092.

SQL Server Execution Times:
CPU time = 7921 ms, elapsed time = 13519 ms.

SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 13781 ms.

View 2 Replies View Related

Converting Date And / Or Time From Char

Jun 3, 2014

converting date and/or time from character string.Got this error message: "Msg 241, Level 16, State 1, Line 7...Conversion failed when converting date and/or time from character string."

Here's my query:
DECLARE @StartDate AS varchar(30)
DECLARE @EndDate AS varchar(30)
SET @StartDate = (CONVERT(varchar(20),'01-05-2014', 101))
SET @EndDate = (CONVERT(varchar(20),'31-05-2014', 101))

[code]....

View 2 Replies View Related

Transact SQL :: Converting Text Value To Time

Jun 4, 2015

Table contains field defined as text. First 12 characters will be date format 'mm/dd/yyyy'. then the next 3 characters could be:

9A, 12P, 3P, 7A or LTL

I would like to convert '9A' to be 09:00AM, so that I can sort by that converted field.

'12P to be 12:00PM    and so on....

I have tried various form of case with substring and convert commands, but cant' get the solution.  I can not change text field to varchar in table.

View 13 Replies View Related

Converting Date And / Or Time From Character String

Oct 22, 2013

My Query is as shown below

Declare @FROMDATE DATETIME
Declare @THRUDATE DATETIME
Declare @Parm Varchar(250)
set @FROMDATE = '09/25/2013'
set @THRUDATE = '09/28/2013'
set @Parm = 'FROMDATE=' + @FROMDATE + ';THRUDATE=' + @THRUDATE

I am getting an error at above line saying that

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

View 8 Replies View Related

Conversion Failed When Converting Date And Or Time

May 14, 2014

I am getting the following error :

conversion failed when converting date and or time from character string

I am using Sql Server 2008.(database designed for sql 2005 later moved to sql server 2008).

Pickup_time and actual_Pickup_time are varchar(5) in database.

What is wrong with this query?

Query:

SELECT COUNT(Trip_ID) AS OntimePickupCount
FROM MyTABLE
WHERE Start_Dt BETWEEN '01/01/2014' AND '04/30/2014'
AND (DateDiff(minute, CAST (Pickup_Time AS time), CAST (Actual_Pickup AS time )) BETWEEN 0 AND 15
OR DateDiff(minute, CAST (Actual_Pickup AS time), CAST (Pickup_Time AS time) ) BETWEEN 0 AND 15)
AND Actual_Pickup IS NOT NULL AND Actual_Dropoff IS NOT NULL

View 4 Replies View Related

Converting Varchar Time HHMM To 24 Hour HH:MM:SS?

Oct 29, 2014

How can I do this? I have a column that is a varchar and times are stored like this:

0600
1240
0145
2335

How can I get those to HH:MM formats? I've tried this but I don't know if it's the best way, plus there are seven 0s after the MM:

convert(time,LEFT(b.status_time,2) +':'+ RIGHT(b.status_time,2))

View 2 Replies View Related

Converting Datestamp To Separate Date And Time Stamp

Jan 11, 2007

I need to separate the date stamp (which looks like this 2006-10-05 09:08:41.000) into the date in this format 05OCT2006 and then the date stamp separate in this format 09:08. Thanks!

View 2 Replies View Related

SQL Server 2012 :: Inconsistent Results When Converting To Time?

Jun 5, 2014

I have a lot of rows of hours, set up like this: 0745, 0800, 2200, 1145 and so on (varchar(5), for some reason).

These are converted into a smalldatetime like this:

CONVERT(smalldatetime, STUFF(timestarted, 3, 0, ':')) [this would give output like this - 1900-01-01 11:45:00]

This code has been in place for years...and we stick the date on later from another column.

But recently, it's started to fail for some rows, with "The conversion of a varchar data type to a smalldatetime data type resulted in an out-of-range value".

My assumption is that new data being added in is junk. If I query for these values and just list them (rather than adding a column to convert them also) that's fine, of course. I've checked all the stuffed (but not yet converted - so 11:45 rather than 1145) output to see if it ISDATE(), and it is. There are no times with hours > 23 or minutes greater than 59 either.

If I add the CONVERT in, we see the error message. But here's the oddity, if I place all of the rows into a holding table, and retry the conversion, there is no error. It's this last bit that is puzzling me. Plus I can't see any errors in the hours data that would cause a conversion problem.

I've put the whole of this into a cursor to try to trap the error rows too, but all processes fine. Why would it fail if NOT in a cursor?

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved