snufse
12-18-2003, 06:22 AM
Happy holidays !!
I am looking for a class/method or code that will convert date to ccyymmdd format. Also I am looking for same to convert time from am/pm to 24 hour format. In any one can help I would appreciate it. Thank you.
00100b
12-18-2003, 06:24 AM
See the Format function in VB's Help files (MSDN).
' Example usage for date format
Debug.Print Format(Date, "yyyymmdd")
' Example usage for time format
Debug.Print Format(Time, "Hh:Nn")
DOH! Still getting used to having VB.NET Forums
Csharp
12-18-2003, 07:01 AM
vb.net has a lot of inbuilt functions for the job , take a look at the DateAndTime namespace :)
here's a couple of simple examples...
'///time...
Dim time As String = DateAndTime.Now.TimeOfDay.Hours & ":" & DateAndTime.Now.TimeOfDay.Minutes & ":" & DateTime.Now.Second
MessageBox.Show(time)
'///date...
Dim dt As String = DateAndTime.Now.ToShortDateString '/// 18/12/2003
Console.WriteLine(dt)
'/// or
dt = DateAndTime.Now.ToLongDateString '/// 18/December/2003
Console.WriteLine(dt)