Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display a Date Field 1

Status
Not open for further replies.

zimmer9

Programmer
Jan 12, 2005
66
US
I imported Table A from a mainframe file. One of the fields I imported is "Date Of Birth" which has a format of yymmdd.
I defined this field as a text field because it has a field length of 6.

An example of a value for 1 record on Table A for this Date Of Birth field is 580723. I created a report to display the Date Of Birth. I defined the Date Of Birth field in the Report as a text box control. Is there a way to convert the this Date Of Birth value from 580723 (as per the Table A value in the Date Of Birth text field) to a display value of 07/23/58 using the Control Source Property of the Text box control on the Report.
 
use Left, Right and MID to parse out the month, day and year. Use Cdate() to convert to a date:

CDate(Mid([DateOfBirth],3,2) & "/" & Right([DateOfBirth],2) & "/" & Left([DateOfBirth],2))

You can use FORMAT property of the text box to format it as you wish.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
zimmer9,
It isn't generally a good idea to post the same question in more than one thread/forum. I think my response in another thread handles the century a little better. I also pointed out in the other thread that you should consider storing a real date in the DOB field. You want a date, store a date.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Hey Duane--sorry I didn't notice a previous post by Zimmer9 or I would have red-flagged this one.

Zimmer9--I noticed you've duplicated even a different post. Please stop it.

g

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top