Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

How to trim the last 6 characters from a DateTime Variable myDate = "02/03/2011 22:44" so that myNewDate ="02/03/2011"

I have a DateTime Variable myDate in Visual Basic Project in Visual Studio 2010.
I need code that will remove (trim)  the last 6 characters of the text contained in this variable and store the remaining characters in a new DateTime variable myNewDate.
So if
myDate = “02/03/2011 22:44”
after triming
myNewDate = “02/03/2011”
That is basically I have removed the characters representing time from myDate.
Thank you for your help in anticipation
0
FaheemAhmadGul
Asked:
FaheemAhmadGul
1 Solution
 
PagodNaUtakCommented:
myDate = “02/03/2011 22:44”
MyNewDate = DateTime.Parse(myDate).ToShortDateString();
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
why try... you should to myDate.ToString("MM/dd/YYYY") to get the result you need.
0
 
FaheemAhmadGulAuthor Commented:
Many thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now