String To Date Conversions

Apr 6, 2006

Having some trouble converting strings to dates. I am using a .dtsx package and have figured out how to use a derived column to convert the string to a new string which is a valid date. The problem is now converting the column data type to date. I insert a new data conversion step to convert the vchar field to date, then when it runs it fails on this step. Error is

The conversion returned status value 2 and status text "The value could
not be converted because of a potential loss of data."


If I leave out the data conversion step and run the package, then manually change the data type to date it warns with the same message, but if I accept it converts correctly.

 

Here is my derived column code

REPLACE(SUBSTRING([Data Conversion 1].START_OF_EXECUTION,1,10) + " " +
RIGHT([Data Conversion 1].START_OF_EXECUTION,8),".",":")


Please Help

View 9 Replies


ADVERTISEMENT

About Date Conversions

Feb 19, 2008

 Hi All,    I struck by a issue, In a table(tblMemberPayments) i had two columns one is to hold (month) as CHAR and other one is to hold (year)  as INT. Now i need to implement search for this table based on the dates given , I mean i need to get the records from this table in between any two dates given by the user (Eg : feb 2007 to feb 2008). While retriving i am unable to type cast the things as required for the above case. I am getting an error unable to convert varchar to datetime while using CONVERT FUNCTION the same thing a raises while using DATEDIFF FUNCTION  .help me if any one knows the solution . here are the couple of ways i tried    1) 'CONVERT(varchar(10),(tblMemberPayments.ExpirationMonth + tblMemberPayments.Expirationyear),1) between CONVERT(varchar(10),''feb 2007'',1)       AND CONVERT(varchar(10),''feb 2008'',1)'  Msg 245, Level 16, State 1, Line 1Conversion failed when converting the varchar value 'Apr' to data type int. 2)'datediff(m,Cast(tblMemberPayments.ExpirationMonth + tblMemberPayments.ExpirationMonthint as datetime), ''Feb 2008'') >= 0 and datediff(m, cast(tblMemberPayments.ExpirationMonth + tblMemberPayments.ExpirationMonthint as datetime), ''Feb 2007'') <= 0'   Thanks & Regards,   Sudheer.Y    

View 2 Replies View Related

DATE CONVERSIONS

Jul 25, 2007

HI ALL,

declere @d varchar(10)
declare @t varchar(10)

set @d=convert(varchar,'7/25/2007 10:10:53',101)
set @d=convert(varchar,'7/25/2007 10:10:53',108)

it returns as
@d=7/25/2007
@t=7/25/2007

but @t should be equal to 10:10:53

what's wrong in the conversions


Malathi Rao

View 2 Replies View Related

Century Date Conversions

Jul 20, 2005

Hi,I'm trying to load date fields into SQLServer using DTS, but theformat of the raw data is the number of days since 1 Jan 1900. How doI convert this to a useful format, is there a standard conversionroutine?ThanksTim

View 2 Replies View Related

Derived Column - Date Conversions?!?

May 1, 2007

It was my understanding earlier that -- it is mandatory to have a Derived Column for a DATE String in a Flat File
to be loaded properly into a table with "datetime" column type

However, i tried running my package with the Input Column as "DT_STR" and the Destination on the table is DATETIME.

Looks like the process went on fine.. Am i missing something here?

My Date Format from the source looks like -- "DD-MON-YY"

Regards

View 1 Replies View Related

Date Format Conversions In SSIS

Oct 11, 2006

Hi

I am quite new to SSIS and have been given the task of importing some data from a text file into the database. The data contains dates which are in the American format of mm/dd/yyyy. I need them in the datadase in the format of dd mon yy.

I realise I could load it and do a SQL task to convert once it is in the database but ideally i would like this data transformed before it is loaded into the tables.

any suggestions will be gratefully recieved.

Best regards

View 1 Replies View Related

Date Function - Conversion Failed When Converting Date And / Or Time From Character String

Mar 18, 2014

I have the following

Column Name : [Converted Date]
Data Type : varchar(50)

When I try and do month around the [Converted Date] I get the following error message

“Msg 241, Level 16, State 1, Line 2
Conversion failed when converting date and/or time from character string.”

My Query is

SELECT
month([Created Date])
FROM [FDMS_PartnerReporting].[Staging].[Salesforce_MarketingReporting]

View 7 Replies View Related

Transact SQL :: Due Date - Conversion Failed When Converting Date And / Or Time From Character String

Nov 16, 2015

SELECT * ,[Due]
  FROM [Events]
 Where Due >= getdate() +90

This returns the error: Conversion failed when converting date and/or time from character string

Why would this be? How to cast or convert this so that it will work? 

View 24 Replies View Related

Help Needed Little Urgent---how To Convert The String Date To Standard Date Format In SQL Table

Sep 28, 2007

Using DTS package in 2000 version, I am dumping TXT file contents into SQL Table,

I have one column having date in format YYYYMMDD(20070929) and corresponding column in SQL is datetime, but it fails on data type mismatch.

I have no choice of making date column in SQL to string or Varchar etc,

is there any way to make that date column in SQL to convert the value upon transformation from format (YYYYMMDD) to M/DD/YYYY (9/29/2007).

many many thanks,

View 2 Replies View Related

Import Flat Text File String Date To Database Date

Jan 30, 2007

I asked this question below, but the answer was that the conversion will take place automatically, but I can't get that to happen. I have a flat file with an 8 position field that I identify as string (and I also tried date) that is yyyymmdd and it needs to go into the database field that is datetime format. IS there something I am doing wrong with the definition of it, or do I need to add some kind of conversion, and if so, what and how would that be done. I'm a dts Sql2000 expert, but the SSIS thing is driving me crazy. I have a ton of dts' to convert and the migration tool doesn't work because there are a lot of active X scripts in them. thanks for your help. Boston Rose

View 1 Replies View Related

Convert String To Date Independent Of Date Format

Feb 15, 2008

Hi,

I Have this simple convertion in a Script component


Dts.Variables("dateOfProcess").Value = CDate(lineMCF.Substring(30, 2) + "/" + lineMCF.Substring(28, 2) + "/" + lineMCF.Substring(24, 4))



this works fin in my development environment which has a spanish version of SQL Server and uses "DD/MM/YYYY" as date format.

but the production environment has an english version of SQL Server and "MM/DD/YYYY" date format, so the package crashes in this server.


How do I convert the string to date not depending on the SQL server language.

thanks.

View 2 Replies View Related

How To Convert Date String To Date Time

Jan 8, 2013

I have a table in which a date value is stored as varchar.some of these values are stored ina dd/mm/yyyy format and other values are stored in a yyyy-mm-dd format..Now I wish to retrieve some data by querying between two dates. However I need to convert the varchar date value to datetime in order to do this but since the date value is in two different formats, the following doesn't work.

select date_value
from my_table
where CONVERT(DATETIME, date_value, 103) between @date1 and @date2

How can you convert the date value to datetime when its stored in mutiple formats. I can't change the table itself as I dont have admin privelages.

View 14 Replies View Related

Datetime Conversions

Dec 6, 2007

In my DB I have strings which are all 8 characters long and all pass the isDate == 1 thing so everything row can be converted into a date.

When I run a select convert(datetime, value) it gives me an error saying that it's unable to convert datetime from string. However when I insert everything into a temp table and run each row individually, it converts fine.

Any ideas as to what I'm doing wrong? I've checked the date settings on SQL 2005 SP2 and the host itself and everything seems correct. I've been stuck on this all day and any help is very much appreciated.

View 12 Replies View Related

Sum Column Values After Conversions

Apr 11, 2014

I have this query where I do certain conversions and on top of this how can I sum the column values.

'$ '+ Replace(CONVERT(varchar,CAST(Total_Amount AS money),1) ,'.00','') as Total_Amount,
'$ '+ Replace(CONVERT(varchar,CAST(Monthly_Amount As money),1),'.00','') as Monthly_Amount,

View 2 Replies View Related

Data Type Conversions

Sep 25, 2006

What are the pros/cons of datatype conversions using the advanced properties of the source adapters or transformation components themselves vs. using the data conversion transformation? Sometimes I am able to do all the conversions I need using the advanced properties rather than use a data conversion component, but didn't know if this was considered bad practice, or has some other impact that isn't immediately apparent.

Thanks

Kory

View 2 Replies View Related

Parameter Conversions Question From SQL Server

Mar 22, 2004

I have a question regarding a casting error I recieve when I explictly assign a value to a value in a stored procedure.......
The value pstrLoginName is a public string defined in a code module
The stored procedure is NVARCHAR Datatypes.....

Here is the Stored Procedure

CREATE procedure dbo.Appt_GetPermissions_NET
(
@LoginName nvarchar(15),
@Password NvarChar(15),
@DeleteScan bit Output

)
as
select

@DeleteScan=UserP_DeleteScan
from
Clinic_Users
where
UserName = @LoginName
and
UserPassword = @Password

GO


Here is my error

Specified cast is not valid
Line 194: cmdsql.CommandType = CommandType.StoredProcedure
Line 195:
Line 196: parmLogin = cmdsql.Parameters.Add("@LoginName", SqlDbType.NVarChar, 15).Value = pstrLoginName
Line 197: parmPassword = cmdsql.Parameters.Add("@LoginPassword", SqlDbType.NVarChar, 15).Value = pstrLoginPassword
Line 198: parmDelete = cmdsql.Parameters.Add("@DeleteScan", SqlDbType.Bit)

my vb .net code to execute this

Public Sub ObtainPermission()


'get the needed data
Dim consql As New SqlConnection("Server=myserver;database=APPOINTMENTS;uid=webtest;pwd=webtest")
Dim cmdsql As New SqlCommand
Dim parmLogin As SqlParameter
Dim parmPassword As SqlParameter
Dim parmDelete As SqlParameter

cmdsql = New SqlCommand("Appt_GetPermissions_NET", consql)
cmdsql.CommandType = CommandType.StoredProcedure

parmLogin = cmdsql.Parameters.Add("@LoginName", SqlDbType.NVarChar, 15).Value = pstrLoginName <----error occurs here

parmPassword = cmdsql.Parameters.Add("@LoginPassword", SqlDbType.NVarChar, 15).Value = pstrLoginPassword <---I'm sure it will happen here then
parmDelete = cmdsql.Parameters.Add("@DeleteScan", SqlDbType.Bit)
parmDelete.Direction = ParameterDirection.Output

consql.Open()
cmdsql.ExecuteNonQuery()

'obtain rights

pstrPermissions = cmdsql.Parameters("@DeleteScan").Value
consql.Close()

End Sub

View 3 Replies View Related

SQL Data Type Conversions And DataRows

Sep 20, 2005

Hi all,I have a DataRow that I'm attempting to insert into SQL.  The row has an item I"ll refer to as row["AbsorbtionDeficiency"].  I'm filling this data row from a ODBC connection to a propriatary database.  Now I want to insert this data into SQL where the same row data type is "money".I'm not to familiar with the different data types, but the long and short of it is this.  When I build my SQL Insert statement, sometimes this value is blank, sometimes it's 0, and sometimes it will have a dollar amount(no formating  just the numeric).  How to I get this data out of the row in a format that SQL understands... Since I'm creating a  SQL string the datatype of the row I assume doesn't matter, so I"m doing a .ToString() when I build the statement.Do I need to do a CAST('0' AS MONEY) to each line that is money type?  Or is there an easier way?I would insert the code, but it's a pretty masive statement and I don't think it's really needed yet.ThanksJosh

View 1 Replies View Related

Sp_executesql Max 10 Data Type Conversions?

Apr 4, 2008

I can't get sp_executesql to accept more than 10 converted parameters in one execution. A stored procedure loops through a table variable that presents up to 100 parameters and their named data types. I've tried selecting into sql_variant and nvarchar variables and converting them to the named data type in the loop.
sp_executesql is outside the loop.
For the first 10 parameters sp_executesql recognizes the data type conversions of the variables that hold the parameter values, but then it fails to accept the conversions of the 11th and subsequent variables. Is there a limit to the number of conversions that sp_executesql can cope with?

View 5 Replies View Related

Import From Access - Datatype Conversions

Jul 6, 2006

I have to do a lot of inporting from Access files.  Is there a place where I can change the default datatype conversion for Access Text from nvarchar to varchar?

Thanks.

Kato

View 3 Replies View Related

How To Handle Multiple Column Conversions

Jan 26, 2006

I have multiple columns in a table that I only want to convert if they are not null or of the proper type. I don't really want to redirect the whole row if one of the conversions fails, rather I would just not want to do the cast or set it to another value. In this scenario is it better to use a custom script or multiple tasks? The multiple tasks seems like a lot of overhead for processing the same data. Just curious how others handle this scenario as it seems as though it has come up quite often on our current project? Thanks for the assistance.

-Krusty

PS: Is it possible to embed evaluation statements along with conversion statements in a task expression? e.g. (len(trim([Column1])) > 0) substring([Column1], 1, 4)

View 1 Replies View Related

Importing A Csv Into Sql Server, Problems With Field Conversions

Nov 13, 2004

I'm importing a csv file into sql server and everything is working fine however here are my problems.

The csv file fields contain some money fields and even though my db column type is money the dts package console complains that my data type from the csv is of type string 'for the money value' and cannot be inserted into the db field because they don't match. I changed the db field to nvarchar and hey presto it works fine. Problem is that this is no good because the data in the db is no longer a money value and therefore I cannot query the way I should.

So basically how do i map my csv to pass its values as the right types instead of just string values. If this was in c# i could just assign the parameter types accordingly but I'm not sure how to with sqlservers dts package.

Any help!!!!!

View 2 Replies View Related

DB Conversions - SQL Server 2000 X 2005 Express

Jun 1, 2006

Recently I decided to start using DotNetNuke, which uses an SQL Server database. My webhoster offers SQL Server 2000, and I was able to install and run DNN successfully there. However, I wish to have a local copy of DNN on my PC with the same contents as is on the web. It means that I need either to convert SQL Server 2000 database to my local SQL Server 2005 Express database, or vice versa.

Although I programmed in (Visual) FoxPro for many years, I am new to SQL Server and I am overwhelmed by the vast number of new terms. Can anyone tell me in simple English, how to perform the above mentioned conversions? My webhoster allows me to backup the SQL Server 2000 database in an *.sql file, but how shall I convert this file into an SQL Server 2005 Express *.mdf file?

View 6 Replies View Related

Username Password Conversions On Upgrade To 2005

May 23, 2008

Am getting ready to perform upgrade/migrate from 2000 to 2005 and have concerns about all the usernames/passwords converting accurately, as the existing 2000 instance has hundreds of them (am used to conversions with few usernames/passwords). Any suggestions as to the best way to proceed. The upgrade/migration is being done on the same box. Will a straight upgrade convert the master db cleanly with u/p, what issues does a migration on the same box present? Thanks.

View 4 Replies View Related

Alter Table Type Conversions With Default

Apr 29, 2008

I'm trying to write some code that will alter column to change its type, in this case from Nvarchar to Int, but I'm not sure if there will be any columns that are uncovertable (say, there's a string that does not have an Int value). In this case, I'd like it to default to 0. Is there a way to write a T-SQL statement to do this, or will I have to write an UPDATE stamement first to clear out any problem cases?

View 1 Replies View Related

SQL String - Date More Than, And Less Than

Mar 12, 2007

Hi,
Im having a problem with a SQL string. Im not that great a building them and just need a bit of help. For example, my table has many fields, the 2 i need to concentrate on are; "Date1", and "Date2", these fields are VarChar(8). I also have a webpage thats going to build a report, that has 2 textboxes in with 2 dates, these textboxes are being used as a Date range (From > To). When a user submits the form, the query needs select all dates similar to this kinda thing (from >= "Date1" and to <= "Date2") if that makes sense. My Date format is (DD, MM, YY) BTW.
Thank you
Help is much appreciated.

View 2 Replies View Related

String Value To Date?

Aug 15, 2013

I'm currently working on a project, i have a source of data that exports the date as a sting.

This data needs to go to a date field.

Here are some examples.

Mon 4 Feb 2013, 17:00
Fri 28 Jun 2013, 14:51
Mon 4 Feb 2013, 16:58
Mon 29 Apr 2013, 09:01
Fri 5 Apr 2013, 01:05
Mon 4 Feb 2013, 17:06

I've wrote this and it is a work in progress.

DECLARE @string VARCHAR(30)
SET @string = 'Fri 28 Jun 2013, 14:51'
SELECT @string
SELECT CONVERT(DATE, SUBSTRING(@string, 5, 2) + '-'
+ CASE WHEN SUBSTRING(@string, 8, 3) = 'Jan' THEN '01'
WHEN SUBSTRING(@string, 8, 3) = 'Feb' THEN '02'

[Code] .....

View 4 Replies View Related

Date To String

Oct 20, 2006

I have the following query which I converted from MS-Access. Its showing error due to concatenation of string and date after I converted Date() to GETDATE()

SELECT
tblCurrent.AutoNumber,
tblCurrent.CompanyName,
-(TotalAmount) AS Amount,
GETDATE() & ' Recd ' & [ParticipantInfo] AS Comment,
'No' AS RefundToBeProcessed,
tblCurrent.Department,
FROM tblCurrent

How do I solve it?

View 6 Replies View Related

Convert String To Date In DTS

Dec 7, 1999

I'm using SQL 7.0 SP1.

I am using DTS to read in a date with the format of YYYYMMDD. I am trying to convert this date to MM/DD/YYYY and then use the CDate function with the following code to load it into a Datetime column in SQL Server:

Function Main()
strDate = DTSSource("Col002")
strYear = Left(strDate, 4)
strMonth = Mid(strDate, 5, 2)
strDay = Right(strDate, 2)

strHoldDate = strMonth + "/" + strDay + "/" + strYear

DTSDestination("DateName") = strHoldDate
Main = DTSTransformStat_OK
End Function

My DTS package will execute without errors, but it does not add the row. I have been successful using CDate when the source date is in the format MM/DD/YYYY.

Also, do you have any tips on how to debug DTS? How to see what's in a variable, etc.?

Thanks!
Lisa

View 1 Replies View Related

Inserting Date Into String

May 5, 2008

Hi again, I am having troubles inserting a datetime value in a table to a string. what iw ant to do is have it be sent in an email. its an attendance email. here is the code i have right now:

select @summaryreport = isnull (@summaryreport + '; ',''+ char(13))+ '<BR>' +'Instructor '+instructor + ' Student ' + Fname + ' ' + Lname + ' - ' + classname +' ' + classdate from #tabledata

i get this as an error

Msg 241, Level 16, State 1, Line 92
Conversion failed when converting datetime from character string.

View 1 Replies View Related

Convert To Date From String

Oct 29, 2014

In our ERP system we have a field which is a date-picker in the user front end, but the value is stored in an NVARCHAR field and not always consistently. How can I convert this to a date (preferably in the format YYYY-MM-DD HH:MM) that I could use in a calculation?

select code, spec_value from spec_checklist_remind where spec_checklist_id = 17

code spec_value
------------ -----------------------------------------------------------------------
05MC0001 22/07/2014
05MC0002 23/07/2014
06MT0001 01-May-2014
06MT0002 01-May-2014
06MT0006 01/05/2014
06MT0007 01-May-2014
06MT0008 01/05/2014

View 5 Replies View Related

Converting String To Date

Aug 12, 2005

Hello,I try to convert a pseudo datetime string into a date. In Oracle I can doto_date( MyDate, 'yyyymmddhh24miss' ); how I can do this with MS SQL ?thanks and regardsMark

View 2 Replies View Related

SQL Date Field To String

Mar 17, 2008

I am running a converted DTS package which executes a stored procedure which extracts fields from a SQL database table and puts them to a flat file. Two of the fields are datetime fields. The stored procedure does not convert the dates, and under SQL 2000 DTS the fields extract as strings in format yyyy-mm-dd hh:mms. When this gave me an error in SSIS, I added a data conversion task between the Ole DB Source and the Text file destination to convert the two fields to DT_STR format and used the converted fields in my mapping for the text file. I am still getting an error on this:

-1071636319,0x,Data conversion failed. The data conversion for column "mm_hdr_process_date" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page."

The target code page is 1252 (ANSI) and I have tried several variations of length, and I still get this error.
Any suggestions? I would prefer not to have to change every stored procedure we have which may do this.
Thanks for any help.
MaryKate

View 6 Replies View Related

String To Date Conversion

Apr 16, 2008



I have a column llike this 041008 (char datatype). I want to convert this to date datatype. how to do this.
Thank you.

View 6 Replies View Related







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