(DT_STR) to (DT_DATE)

  • iam trying to convert a column which is of datatype (DT_WSTR) to (DT_DATE).

    first i have convert (DT_WSTR) to (DT_STR) and then trying to convert it to (DT_DATE) but i keep getting this message----

    [Data Conversion 1 [172]] Error: Data conversion failed while converting column "upd_dttm" (62) to column "Copy of upd_dttm" (185). The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data."

    NOTE: this column has null values in it

  • I can't tell from the error descriptor which part of the conversion is throwing the error. I can suggest that for dealing with date fields which may contain null values that you check for them explicitly in a derived column. As an example, I tend to use something like:

    ISNULL(DOB) ? NULL(DT_DATE) : (DT_DATE)(SUBSTRING(DOB,5,2) + "/" + SUBSTRING(DOB,7,2) + "/" + SUBSTRING(DOB,1,4))

    (Where DOB is an inbound text of format YYYYMMDD)

    for converting from text to date types.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply