How to extract the year from datetime into a string with VB.NET

1 Answer

0 votes
Imports System
  
Public Class Test
    Public Shared Sub Main()
        Dim dt As DateTime = DateTime.Now
    
		Dim s As String =  String.Format("{0:yyyy}", dt)
          
        Console.WriteLine(s)
    End Sub
End Class
  
  
  
' run:
' 
' 2022
'

 



answered Oct 30, 2022 by avibootz

Related questions

1 answer 124 views
1 answer 170 views
1 answer 213 views
2 answers 215 views
2 answers 217 views
2 answers 250 views
...