If no date found how to replace blank with null

Hi all,

I am able to change the date format to specific format and stored into excel.
If no date found in input file that blank data needs to be replace with “null”.
Seq blank to NF.xaml (13.2 KB)
This is my workflow. Above workflow works fine if we have date in sample file.
If date is not present in input file, it shows error.
Assign: String was not recognized as a valid DateTime.
test pdf.txt (16 Bytes)
Please help me on this.

Thanks & Regards,
Lakshmi

Hey!

Try like this:

  1. Read the excel ->Dt
  2. Take For each row in DataTable pass the Dt
  3. Take one Assign activity Create a string variable Date1 pass the expression like this
Assign Date1 = CurrentRow("ColumnName").ToString.Trim

Take one if condition - Pass the expression like this

String.IsNullorEmpty(Date1ToString)

In then block assign like this

Assign Date2 = "null"

in Else block

Assign Date2 = Cdate(Date1).ToString("dd-MM-yyyy")

Regards,
NaNi

Hi @THIRU_NANI ,

I am facing this issue in data extraction. After extracting the data will be written into excel.
Seq blank to NF.xaml (13.4 KB)
test pdf.txt (16 Bytes)
image
If date present in input text file is working, if in input file the data is blank its not working getting error.
This is my workflow and input sample file. Please look on it.

Thanks & Regards,
Lakshmi

Hello @lakshmi.mp

You can also do this with only one Assign activity.

Assign : Date2 = If(String.IsNullOrWhiteSpace(Date1), Nothing, Convert.ToDateTime(Date1).ToString(“dd-MM-yyyy”))

Regards,
Kardelen.

1 Like

Hey!

Updated the sequence…

Find the attached File below

Seq blank to NF.xaml (12.5 KB)

Regards,
NaNi

1 Like

Hi @THIRU_NANI ,

image
Its working for both date and no date input files.


Added str1 in for each loop.

Thanks a lot it’s working now.

Regards,
Lakshmi

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.