Dt & DateTime format in error

Hi,

What am I doing wrong?

The state I am trying to translate is 221222

Hi @Ertan_AY ,

I believe the format should be changed from yyyyMMdd to yyMMdd

Hi @Ertan_AY
give “yyMMdd” instead of “yyyyMMdd”

Hi,
Please check the date format before passing the variable to assign. Used WriteLine\ Message box activity and check the date format of column.

image
I think there is an error here :confused:

Hi @Ertan_AY

Change “yyyyMMdd” to “yyMMdd”

Like this
DateTime.ParseExact(row(“Column Name”).ToString.Trim,“yyMMdd”,CultureInfo.InvariantCulture)

@Ertan_AY , You should have substituted yyMMdd in place of yyyyMMdd as we see in the Screenshot, Note that earlier the .ToString("yyyyMMdd") was not used or not shown.

Hey Paas like this DateTime.ParseExact(row(“columnName”).trim,“yyMMdd”,CultureInfo.InvariantCulture)

1 Like


very interesting

Hi @Ertan_AY,

The code DateTime.ParseExact(row("Islem Tarihi").Trim, "yyyyMMdd", CultureInfo.InvariantCulture) is parsing the date string in the format “yyyyMMdd” to a DateTime object. Then the ToString method is used to format this DateTime object to a string in the format “yyMMdd”.

The potential issue with this code is that if the input string in row("Islem Tarihi") is not in the format “yyyyMMdd”, then a FormatException will be thrown by the ParseExact method. To handle this, you can use a TryParseExact method instead, which returns a boolean value indicating whether the parsing was successful or not. Here’s an example:

Dim dateString As String = row("Islem Tarihi").Trim()
Dim inputFormat As String = "yyyyMMdd"
Dim outputFormat As String = "yyMMdd"

Dim dateValue As DateTime
Dim parseSuccess As Boolean = DateTime.TryParseExact(dateString, inputFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, dateValue)

If parseSuccess Then
    Dim formattedDate As String = dateValue.ToString(outputFormat)
    ' Do something with formattedDate
Else
    ' Handle parsing error
End If

@Ertan_AY ,

There is misplace of brackets in the expression used :

DateTime.ParseExact(row("Your Column Name").ToString.Trim,"yyMMdd",CultureInfo.InvariantCulture).ToString("ddMMyyyy")

Let us know if the above Expression doesn’t work.


@supermanPunch

image
@supermanPunch

@Ertan_AY

Remove .toString from the end.
DateTime.ParseExact(row(“Your Column Name”).ToString.Trim,“yyMMdd”,CultureInfo.InvariantCulture)

@Ertan_AY ,

I believe the variable used to store the value is a DateTime Type, if so you wouldn’t need to use the .ToString("ddMMyyyy") at the end of Expression. Remove this part and check with the expression.

Also, If needed to convert to String format, we can do so after using the variable assigned.

NewDate.ToString("ddMMyyyy")
1 Like

Merhaba @Ertan_AY ,

Try doing like this:


Convert.ToDateTime(DateTime.ParseExact(row("iĹźlem tarihi").ToString, "yyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString("MM/dd/yyyy HH:mm:ss"))

and store it in your DateTime variable.


this way it gives correct output but this error is repeated

Abi did you use this one? I can’t see it in your code…just copy paste it and let me know if it works.


Convert.ToDateTime(DateTime.ParseExact(row("iĹźlem tarihi").ToString, "yyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString("MM/dd/yyyy HH:mm:ss"))


@ahmad.sultan

can you show me the row(“isles Tarihi”) value tu save in the first assing pls