day/month/year parts of a date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello
how do I get the day/month/year part of a date in vb.net?

sample in vb6:
day(13/10/2001) = 13
month(13/10/2001) = 10
year(13/10/2001) = 2001

Thanks
Guy
 
Hello
how do I get the day/month/year part of a date in vb.net?

sample in vb6:
day(13/10/2001) = 13
month(13/10/2001) = 10
year(13/10/2001) = 2001

Thanks
Guy

While, you have the visual basic DataPart function:

Dim dt As New Date(2001, 10, 13) ' or As New DateTime(2001, 10, 13)

Console.WriteLine(DatePart(DateInterval.Day, dt))
Console.WriteLine(DatePart(DateInterval.Month, dt))
Console.WriteLine(DatePart(DateInterval.Year, dt))

Or you can just use the standard date properties:

Console.WriteLine(dt.Day)
Console.WriteLine(dt.Month)
Console.WriteLine(dt.Year)
 
You were sending at the same time as Tom, for the Google searchers. Take the
answer from Tom.

Cor
 
Back
Top