Getting day suffix when using DateTime.ToString()


#1

Hi,
I found code how to do it but problem is how to do in UIPATH.
I believe costume activity is the ans. But i really don’t know how to do that .
Could anyone upload the workflow of it.
VB code:
litDate.Text = DatePart(“dd”, Now) & GetDateSuffix(DatePart(“dd”, Now))

Function GetDateSuffix(ByVal dateIn As Integer) As String

'// returns formatted date suffix

Dim dateSuffix As String = ""
Select Case dateIn
    Case 1, 21, 31
        dateSuffix = "st"
    Case 2, 22
        dateSuffix = "nd"
    Case 3, 23
        dateSuffix = "rd"
    Case Else
        dateSuffix = "th"
End Select

Return dateSuffix

End Function

thanks in advance
Dilip


#2

I think you can use Switch activity in uipath for this.


#3

Thanks @vvaidya. it worked .Your right its quite easy when i tried it.
adding workflow for getting date suffix . :slight_smile:
Main.xaml (11.0 KB)


#4

Or code activity if you’re on community beta.


#5

Do you mean the custom activity? If so, true, it is more scalable.


#6

Not custom activity. Starting with 2017.1.6291 you can use the InvokeCode activity. DateSuffix.xaml (5.5 KB)

Of course a Switch is good too as the complexity here is not too high.

Here’s how it looks:


#7

This is a cool feature! when is the Release date of 2017.1? We just upgraded to 2016.2 last week.


#8

For Studio Pro about one month. But it is already out in CE Beta channel if you want to try it.


#9

Thanks. Will give a try tomorrow.