Solved

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

Posted on 2011-02-24
3
327 Views
Last Modified: 2012-08-13
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
Comment
Question by:FaheemAhmadGul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Accepted Solution

by:
PagodNaUtak earned 50 total points
ID: 34968693
myDate = “02/03/2011 22:44”
MyNewDate = DateTime.Parse(myDate).ToShortDateString();
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 34968695
why try... you should to myDate.ToString("MM/dd/YYYY") to get the result you need.
0
 
LVL 1

Author Closing Comment

by:FaheemAhmadGul
ID: 34968817
Many thanks
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question