?
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
Medium Priority
?
329 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 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

752 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