cmdolcet
asked on
Parsing a Date.Now using vb.net
I am trying to parse a return value of the date.now
I have the following:
The format I am trying to get is the following
<min,hour,date,weekday,mon th,year>
So the returned value above would look like:
<27,01,05,4,9,2019>
Any help would be amazing.
I have the following:
'On a button control I have the following
Dim date1 as Date = Date.now
'I would like to parse the returned value # 9/5/2019 01:27:04 PM#
The format I am trying to get is the following
<min,hour,date,weekday,mon
So the returned value above would look like:
<27,01,05,4,9,2019>
Any help would be amazing.
In .Net we have DateTime data type and everything that you need is available as a property. So, date1.Hour will get you Hours value and so on. All you need to do is use concatenation to get desired results.
date1.Hour & "," & date1.Minute...
https://docs.microsoft.com/en-us/dotnet/api/system.datetime?view=netframework-4.8#properties
date1.Hour & "," & date1.Minute...
https://docs.microsoft.com/en-us/dotnet/api/system.datetime?view=netframework-4.8#properties
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is a function that you could use:
Function Adjustdate(ByVal i As DateTime) As String
' <min,hour,day,weekday,mont h,year>
Return "<" & i.Minute & "," & i.Hour & "," & i.Day & "," & i.DayOfWeek & "," & i.Month & "," & i.Year & ">"
End Function
Function Adjustdate(ByVal i As DateTime) As String
' <min,hour,day,weekday,mont
Return "<" & i.Minute & "," & i.Hour & "," & i.Day & "," & i.DayOfWeek & "," & i.Month & "," & i.Year & ">"
End Function
Open in new window