![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm trying to convert date text to date time. I can use dateserial sucessfully as shown below, however it is not uncommon to receive bad dates in my data feed. Iv'e done a test and added 20051145 as a bad date, but dateserial converts is to 12/15/2005 (just adds the days). dim v_Day dim v_Month dim v_Year v_Day = Cint(Mid( DTSSource("col001") ,7 , 2 )) v_Month = Cint(Mid( DTSSource("col001") ,5 , 2 )) v_Year = Cint(Left(DTSSource("col001"),4)) IF ISDATE(v_day+v_month+v_year)) then DTSDestination("my_date") = DateSerial( v_Year , v_Month ,v_Day ) ELSE DTSDestination("my_date") = null END IF How can I validate and convert? |
#3
| |||
| |||
|
|
What about If v_month < 1 OR v_Month > 12 For v_Days check against the month Or you could use ISDATE(< expression >) Allan "Gary" <Gary (AT) discussions (DOT) microsoft.com> wrote in message news:Gary (AT) discussions (DOT) microsoft.com: I'm trying to convert date text to date time. I can use dateserial sucessfully as shown below, however it is not uncommon to receive bad dates in my data feed. Iv'e done a test and added 20051145 as a bad date, but dateserial converts is to 12/15/2005 (just adds the days). dim v_Day dim v_Month dim v_Year v_Day = Cint(Mid( DTSSource("col001") ,7 , 2 )) v_Month = Cint(Mid( DTSSource("col001") ,5 , 2 )) v_Year = Cint(Left(DTSSource("col001"),4)) IF ISDATE(v_day+v_month+v_year)) then DTSDestination("my_date") = DateSerial( v_Year , v_Month ,v_Day ) ELSE DTSDestination("my_date") = null END IF How can I validate and convert? |
#4
| |||
| |||
|
|
Thanks for your reply Alan. I would like to do it using isdate but when I use: ISDATE((v_month & v_day & v_year)) , it always comes out false??? I also tried "v_year..mm..dd". I also tried using the ISDATE directly on the source data which is the proper usage for ISDATE(col001), still always false. Suggestions... "Allan Mitchell" wrote: What about If v_month < 1 OR v_Month > 12 For v_Days check against the month Or you could use ISDATE(< expression >) Allan "Gary" <Gary (AT) discussions (DOT) microsoft.com> wrote in message news:Gary (AT) discussions (DOT) microsoft.com: I'm trying to convert date text to date time. I can use dateserial sucessfully as shown below, however it is not uncommon to receive bad dates in my data feed. Iv'e done a test and added 20051145 as a bad date, but dateserial converts is to 12/15/2005 (just adds the days). dim v_Day dim v_Month dim v_Year v_Day = Cint(Mid( DTSSource("col001") ,7 , 2 )) v_Month = Cint(Mid( DTSSource("col001") ,5 , 2 )) v_Year = Cint(Left(DTSSource("col001"),4)) IF ISDATE(v_day+v_month+v_year)) then DTSDestination("my_date") = DateSerial( v_Year , v_Month ,v_Day ) ELSE DTSDestination("my_date") = null END IF How can I validate and convert? |
![]() |
| Thread Tools | |
| Display Modes | |
| |