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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with date/time field 1

Status
Not open for further replies.

mbaddar

Programmer
May 10, 2001
120
US
Hi,

I am importing data from a text file into an Access application. One of the fields being imported shows the date and time of a user application submission. This field is coming in in this format: 10/21/2002-21:48. I would like to convert the time portion of this field into non-military time (like 1:00 pm instead of 13:00). I'd also like to split the time portion out so I can display it in a separate textbox on a form. Does anyone know how to both or either of these things?

Thanks,
MBaddar
 
If you can get this into a date field in Access it doesn't matter what the format is. Access stores date and time data as numbers, and you can format the date however you want with the Format method.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.


Remember to reward helpful tips with the stars they deserve.
 
Hi,

Thanks for the tip. The data sits on another database before we import it and this field is in a text format. So, when I try to import it into a date/time access field I receive type conversion errors. So, is there a way I can convert a text field that is storing a date like this (10/21/2002-21:48) to a date. I know in other langauges there is a makedate function. I'm not sure if there's something like this in VB.

Thanks again.
MBaddar
 
Look into CDate in the help files.

You may need to run an update query in which you replace "-" with " ".

Actually, now that I think about it, try running that query and then change the data type of the field. That should do the trick.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.


Remember to reward helpful tips with the stars they deserve.
 
Hi Jeremy,

Thanks a bunch. Your suggestion worked as you described.

Thanks
MBaddar
 
Excellent. Glad to help.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.


Remember to reward helpful tips with the stars they deserve.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top