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

Access Date Problem

Status
Not open for further replies.

md092686

IS-IT--Management
Jul 20, 2007
18
0
0
US
I have a field with dates that are Text 10012007. I want to place a slash between the date as: 10/01/2007. Can an update procedure do this in a query?

 
Are your months always going to be in format of 01 (as opposed to just 1)? In that case the following will work -

Left([dateField],2) & "/" & Mid([dateField],3,2) & "/" & Right([dateField],4)
 
If you want that field to act like a real "date", you'd have to make another field in your table that is a DATE type. Make the update query put the new data into that field. Also might have to wrap it in CDate(blah) to convert it to a date.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 




BTW, the TEXT, 10/01/2007, is ambiguous.

Is it mm/dd/yyyy or is it dd/mm/yyyy?

It is good to use the TEXT in the form yyyy/mm/dd, which is UNAMBIGUOUS.

But you really do not want to ultimatly use TEXT in a table. You want Real Dates. So either force conversion using the # delimiter, like...
Code:
MyDate: #2007/10/01#
or
Code:
MyDate: DateSerial(2007,10,01)
and if your DateText is 10012007, then the conversion would be EITHER
Code:
MyDate: DateSerial(Right([DateTEXT],4),Left([DateTEXT],2),Mid([DateTEXT],3,2))
OR
Code:
MyDate: DateSerial(Right([DateTEXT],4),Mid([DateTEXT],3,2),Left([DateTEXT],2))


Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top