Warning for conversion from String to date
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad
Warning for conversion from String to date
Hi All,
I am checking if the incoming VarChar(10) field is a valid Date or not.
Its a not nullable column. I could have spaces and '0000-00-00' I found some useful post in the which reduced the following warning but I yet receive some of them.
Warning received is
APT_CombinedOperatorController,1: Conversion error calling conversion routine date_from_string data may have been lost [transform/tfmop_functions.C:132]
The input data is of the format yyyy-mm-dd
Below is the check I am doing in the stage variable which holds a value of 0 or 1.
svStageVar=
If Trim(Lnk_Read_PHONE.PHONE_EFF_DATE)='' OR
Trim(Lnk_Read_PHONE.PHONE_EFF_DATE)='0000-00-00'
Then 0 Else If IsValid("Date",StringToDate(Trim(Lnk_Read_PHONE.PHONE_EFF_DATE,'%yyyy-%mm-%dd'))) Then 0 Else 1
the stage variable svStageVar has a value of 0 or 1.
Thanks in advance
I am checking if the incoming VarChar(10) field is a valid Date or not.
Its a not nullable column. I could have spaces and '0000-00-00' I found some useful post in the which reduced the following warning but I yet receive some of them.
Warning received is
APT_CombinedOperatorController,1: Conversion error calling conversion routine date_from_string data may have been lost [transform/tfmop_functions.C:132]
The input data is of the format yyyy-mm-dd
Below is the check I am doing in the stage variable which holds a value of 0 or 1.
svStageVar=
If Trim(Lnk_Read_PHONE.PHONE_EFF_DATE)='' OR
Trim(Lnk_Read_PHONE.PHONE_EFF_DATE)='0000-00-00'
Then 0 Else If IsValid("Date",StringToDate(Trim(Lnk_Read_PHONE.PHONE_EFF_DATE,'%yyyy-%mm-%dd'))) Then 0 Else 1
the stage variable svStageVar has a value of 0 or 1.
Thanks in advance
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad
sendmkpk/devidotcom - both of you are correct, I was wrong. Even though I had written DCOUNT I was thinking in terms of the COUNT function. COUNT("yyyy-mm-dd","-") is 2 and DCOUNT("yyyy-mm-dd","-") is 3. The "#2" part means "<>2". It makes sense to use the COUNT function in this place instead of DCOUNT, though; so the preferred check is
Code: Select all
COUNT(Lnk_Read_PHONE.PHONE_EFF_DATE,'-')#2 THEN 0
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad
Thanks AndrW.
I used the below condition
svCustEffDate=
If Trim(Lnk_Trn_Columns.CUID_ID_EFF_DATE)='' OR Trim(Lnk_Trn_Columns.CUID_ID_EFF_DATE)='0000-00-00' OR Trim(Lnk_Trn_Columns.CUID_ID_EFF_DATE)='1911-11-11' Or Dcount(Lnk_Trn_Columns.CUID_ID_EFF_DATE,'-')<>3 Then '0000-00-00' Else StringToDate(Lnk_Trn_Columns.CUID_ID_EFF_DATE)
svCustCloseDate=
If Trim(Lnk_Trn_Columns.CUST_CLOSE_DATE)='' OR Trim(Lnk_Trn_Columns.CUST_CLOSE_DATE)='0000-00-00' Or Dcount(Lnk_Trn_Columns.CUST_CLOSE_DATE,'-')<>3 Then '0000-00-00' Else StringToDate(Lnk_Trn_Columns.CUST_CLOSE_DATE)
If (svCustEffDate > svCustCloseDate) Then 1 Else 0
I am later comparing the dates...
I yet get the warning
I used the below condition
svCustEffDate=
If Trim(Lnk_Trn_Columns.CUID_ID_EFF_DATE)='' OR Trim(Lnk_Trn_Columns.CUID_ID_EFF_DATE)='0000-00-00' OR Trim(Lnk_Trn_Columns.CUID_ID_EFF_DATE)='1911-11-11' Or Dcount(Lnk_Trn_Columns.CUID_ID_EFF_DATE,'-')<>3 Then '0000-00-00' Else StringToDate(Lnk_Trn_Columns.CUID_ID_EFF_DATE)
svCustCloseDate=
If Trim(Lnk_Trn_Columns.CUST_CLOSE_DATE)='' OR Trim(Lnk_Trn_Columns.CUST_CLOSE_DATE)='0000-00-00' Or Dcount(Lnk_Trn_Columns.CUST_CLOSE_DATE,'-')<>3 Then '0000-00-00' Else StringToDate(Lnk_Trn_Columns.CUST_CLOSE_DATE)
If (svCustEffDate > svCustCloseDate) Then 1 Else 0
I am later comparing the dates...
I yet get the warning
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad
"did not work" doesn't help much in analyzing the problem. What happened? Did the machine crash? Was the output just 0000-00-00? Are you 100% certain that this date column is generated the error messages? Do you know which value of Date is causing this? You can narrow it down to the row - using IsValid and a condition in your transform.
-
- Participant
- Posts: 247
- Joined: Thu Apr 27, 2006 6:38 am
- Location: Hyderabad