Convert Year to two digits

Asked

Viewed 17 times

0

How to convert Datetime.now.year to two digits? Ex: 2021 to 21

My code:

Dim ok As String = DateTime.Now.Year.ToString("yy")
shortyear.text = ok

Prints "yy"

  • just do Dim ok As String = DateTime.Now.ToString("yy") see the example

  • Thank you very much, I tested and it worked too...

1 answer

0

Okay, I managed to solve the problem the easy way.

Dim TimeFormat As String = "yy"
 Sub Yearget()
    yearprint.Text = Convert.ToDateTime(voyagedate.Value).ToString(TimeFormat)
End Sub

Browser other questions tagged

You are not signed in. Login or sign up in order to post.