Solved

Format Textbox to Date

Posted on 2013-06-03
4
438 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now