IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic
  • 2 replies
  • Latest Post - ‏2013-03-19T18:11:07Z by SystemAdmin
SystemAdmin
SystemAdmin
6184 Posts

Pinned topic Validating a text field with Datetime field.

‏2013-03-18T21:21:53Z |
Hello,
I'm trying to validate TEXT input field has a DateTime format and it's not validating properly. I changed my data to a invalid date format/value but it's not validating at all. Any help will be greatly appreciated.

=IF(
VALID(
TODATETIME(
HLTHCOV_COV_EFF_DT Field:HEALTH_COV_RECORD:DETAIL:CopyBook,
"{CCYYMMDDHH24MMSS}") ),
"INVALID"
) = "INVALID" ,
"Incorrect DateTime format",
NONE
)
Updated on 2013-03-19T18:11:07Z at 2013-03-19T18:11:07Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    6184 Posts

    Re: Validating a text field with Datetime field.

    ‏2013-03-19T17:34:31Z  
    Hi,

    the VALID function can't help you there, it's not designed for this usage.

    Depending on the sub-class for your output item, there could be different ways of doing this.

    If you use a TEXT item (which seems the easiest way) then
    =IF ( EITHER ( FROMDATETIME(TODATETIME(HLTHCOV_COV_EFF_DT Field:HEALTH_COV_RECORD:DETAIL:CopyBook,"{CCYYMMDDHH24MMSS}") )),\
    "INVALID")="INVALID", "Incorrect datetime format")

    might be close to what you want (I did NOT test this, nor did I check the rule is valid, but it should be)
  • SystemAdmin
    SystemAdmin
    6184 Posts

    Re: Validating a text field with Datetime field.

    ‏2013-03-19T18:11:07Z  
    Hi,

    the VALID function can't help you there, it's not designed for this usage.

    Depending on the sub-class for your output item, there could be different ways of doing this.

    If you use a TEXT item (which seems the easiest way) then
    =IF ( EITHER ( FROMDATETIME(TODATETIME(HLTHCOV_COV_EFF_DT Field:HEALTH_COV_RECORD:DETAIL:CopyBook,"{CCYYMMDDHH24MMSS}") )),\
    "INVALID")="INVALID", "Incorrect datetime format")

    might be close to what you want (I did NOT test this, nor did I check the rule is valid, but it should be)
    Thank you so very much...I just twicked it a little bit but it works wonderfully. Thank you so very much again.