I can not be converted to date with Datetime.tryParseExact ()

BlankProcess1 .zip (19.9 KB)

According to the title,
The character string “stDate” input to the A1 cell of “Book 1. Xlsx” Sheet 1 is "
It checks whether it is possible to convert the date if it matches one of the arFormats array formats.

If True, I’d like to convert it to the format ‘yyyy year MM month dd day HH hours mm.’
If it is False, please enter A1 cell in date convertible format. I want to display a message saying.

In VisualStudio 2017

    Dim stDate as String = "20190202"
    Dim Formats As String () = {"yyyy年MM月dd日", "yyyy / M / d", "d-MMM-yy", "yyyy-MM-dd", "yyyyMMdd"}
        Dim OutputDate as Datetime
        If DateTime.TryParseExact (stDate, Formats, Globalization.DateTimeFormatInfo.InvariantInfo, Globalization.DateTimeStyles.None, OutputDate) Then
        Console.WriteLine ($ "{stDate} = {Output Date: yyyy年MM月dd日 HH時mm分}")
        End If

The code of OutputDate can be output,
When it becomes Uipath, it becomes “01/01/0001 00:00:00”, and date conversion can not be done at all.

In Xaml that uploaded, its processing and conditional branching are described easily.

The desired result is that the character string entered in stDate,
It will be output in the format “yyyy年MM月dd日 HH時mm分”.

As a separate matter,
In Uipath like the above Console.writeline
How do you output in the description of string interpolation?

I would be saved if you could tell me this too.

It will be helpful if someone tells me.
Thank you very much.

1 Like

Use old-style string.Format("{0} {1: your format srting}", stDate, outputDate)

1 Like

I had the same issue with DateTime.TryParseExact but now it was solved. Try it with ‘Invoke Code’ activity. Because in UiPath any variables cannot get a new value without ‘Assign’ activity. In other words they are arguments. Have a look at the following attachment.
Hope it will work…
BlankProcess2.zip (21.1 KB)

There is a typo:
Correction: In other words they are not arguments.

im having issue with below code:
Dim out_expiry_date As String = Date.ParseExact(“27-NOV-30”, “dd-MMM-yy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MMM/yyyy”)

out_expiry_date displayed as year 1930 instead of 2030.
Issue is for all YY after 30.
Can someone please help!