String was not valid DateTime

Hi…

i have a issue in datatime was not string error… in LINQ Query.

Code:

(From row In  Dt_Attendance.AsEnumerable()
Let chkEmpty = String.Join("",row.ItemArray.Skip(2))
Let Attendance = If(String.IsNullOrEmpty(chkEmpty.Trim),	"Leave","Present")
Let wrkHrs = If(Attendance.Equals("Present"), (Convert.ToDateTime(row("Work End Time").ToString) - Convert.ToDateTime(row("Work Start Time").ToString)).ToString("hh")+
"."+(Convert.ToDateTime(row("Work End Time").ToString) - Convert.ToDateTime(row("Work Start Time").ToString)).ToString("mm"),"00.00")
Let ra = New Object(){
	Attendance,
	If(IsNothing(row("SSFA_LoginTime")) OrElse String.IsNullOrEmpty(row("SSFA_LoginTime").ToString),"00.00.00",Convert.ToDateTime(row("SSFA_LoginTime").ToString).ToString("h.mm.ss")),
	If(IsNothing(row("Work Start Time")) OrElse String.IsNullOrEmpty(row("Work Start Time").ToString),"00.00.00",Convert.ToDateTime(row("Work Start Time").ToString).ToString("h.mm.ss")),
	If(IsNothing(row("Work End Time")) OrElse String.IsNullOrEmpty(row("Work End Time").ToString),"00.00.00",Convert.ToDateTime(row("Work End Time").ToString).ToString("h.mm.ss")),
	wrkHrs}
Select Dt_Hd_Clone.Rows.Add(ra)).CopyToDataTable()

i created mail.xmal file in that file use flow chart activity used to differentiate the Sequence… in one sequence code in working fine without any issue… I created New sequence copy and paste same code without changes… i got the error…

image

How to find the error and fix it…

Thanks

Shyam

@Shyam_Pragash there might be some empty or different format of data is coming in “Work End Time” or “Work Start Time” column

@Shyam_Pragash Instead of convert.ToDateTime can you try with PasrseExtarct method

DateTime.ParseExact(dateString, "d/M/yyyy", 
	System.Globalization.CultureInfo.InvariantCulture)
1 Like

you’re converting datetime also converting to string same time.

Hi @ushu

it working in previous sequence i have created one…

Not working in New sequence today created one…

Thanks
Shyam

Hi…

i Try to clone columns Name but i have to get value also…
Screen shot Attached.

Thanks
Shyam

@Shyam_Pragash Did you run with the current input data that you are using now in your previous sequence.

@Shyam_Pragash ,

We do notice this situation after certain number of Runs. For that we could Clear the Data Contents using Clear method like below :
image

This needs to be done after the Clone

Hi …

its working fine…

Column Name and variable Name are same… only sequence changed…

Thanks
Shyam

1 Like

Hi…

Again i got same error…

image

image

if run AB Sequence in the code is working fine without error if try to run the H-Milk Squence i got above error…

like this i have 5 excel do same acivity…

AB_Sequence and H-Milk Sequence both have same code but only columns are change…

Thanks
Shyam