Solved

Format Textbox to Date

Posted on 2013-06-03
4
469 Views
Last Modified: 2013-06-03
Hi:

I have concatenated the values from 3 text boxes to 1 to be placed within the textbox OOCRun1.

However, I need to format the textbox to date but I am not getting through.

OOCRun1.Text = Day1.Text + CycleNo1.Text + PayYear1.Text
OOCRun1.Text = Convert.ToDateTime(OOCRun1.Text).ToString("MM/DD/YYYY")

Please advise.
0
Comment
Question by:ernie_shah
[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
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 39216728
try this,
        
OOCRun1.Text = Day1.Text + CycleNo1.Text + PayYear1.Text
OOCRun1.Text = DateTime.ParseExact(OOCRun1.Text, "dd/MM/yyyy", Nothing).ToString("MM/dd/yyyy")

Open in new window

0
 

Author Comment

by:ernie_shah
ID: 39216806
The error message " String was not recognized as a valid DateTime" is raised

Example of the data in the fields:

Day1 - 16
CycleNo1 - 4
PayYear1 - 2013

OOCRUN1 -1642013

I need OOCRun1 formatted to 4/16/2013
0
 
LVL 18

Accepted Solution

by:
Rajar Ahmed earned 500 total points
ID: 39216866
Try this ,
        
OOCRun1.Text = Day1.Text & "/" & CycleNo1.Text & "/" & PayYear1.Text
OOCRun1.Text = DateTime.ParseExact(OOCRun1.Text, "dd/M/yyyy", Nothing).ToString("M/dd/yyyy")

Open in new window

0
 

Author Comment

by:ernie_shah
ID: 39216880
Excellent thanks,

Works like a charm.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

707 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