Anyone here who knows how to convert system month,Day,Hour,Minutes,Seconds each into number format like

month=12 (If December)
Hour=12 (In 24 hour format)

Thanks for help in advance...

Recommended Answers

All 3 Replies

Is this what you were looking for:

Dim TheDateTimeRightNow As DateTime = Now

        Dim iMonth As Integer = DatePart(DateInterval.Month, TheDateTimeRightNow)
        Dim iDay As Integer = DatePart(DateInterval.Day, TheDateTimeRightNow)
        Dim iYear As Integer = DatePart(DateInterval.Year, TheDateTimeRightNow)
        Dim iHour As Integer = DatePart(DateInterval.Hour, TheDateTimeRightNow)
        Dim iMinute As Integer = DatePart(DateInterval.Minute, TheDateTimeRightNow)
        Dim iSecond As Integer = DatePart(DateInterval.Second, TheDateTimeRightNow)

or even easier:

Dim thisDate As String = "30.12.2011 5:26:45 AM" 'switch to PM and see the difference
		Dim myDate As DateTime = DateTime.Parse(thisDate)
		Debug.WriteLine(String.Format("{0},{1},{2},{3},{4}", myDate.Month, myDate.Day, myDate.Hour.ToString("G", Globalization.DateTimeFormatInfo.CurrentInfo), myDate.Minute, myDate.Second))

That solves the problem Thank u guys..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.