Reputation: 1357
I am trying to truncate the seconds part from the current Date
Dim nowTime As DateTime = Now.ToShortTimeString
The above code shows time in the format
hh:mm:ss
I want it in the format
hh:mm
The Date Time Picker shows date like this
5/ 1/2011
(There is a space before 5 and before 1)
Dim nowTime As DateTime = Now.ToShortTimeString
The above code shows Date like this
5/1/2011
(There is no space before 5 or 1)
I am trying to compare the current Date and time with the Date and Time in the database.
In the database I have saved the Date and Time as string.
Upvotes: 0
Views: 2142
Reputation: 21864
you need to apply a correct FormatString with DateTime.ToString()
like
dateValue.ToString("hh:mm")
and for the date:
Now.ToString("MM/dd/yyyy")
Upvotes: 1
Reputation: 14781
Use the following:
String format = "What ever format you want"; // Examples: "hh:mm", "MM/dd/yyyy"
String value = youDateTimeObject.ToString(format);
Upvotes: 1