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 115 views
1 answer 160 views
1 answer 199 views
2 answers 201 views
2 answers 200 views
2 answers 230 views
...