tahirih
asked on
Access - change Data from Text to Date
Hi,
I have a text field, in the format 1/1/2009.
I would like to change this to Date/Time so I can do proper date sorting and querying. I get a message indicating there is not enough memory space.
Please offer how I may alleviate this problem?
Thanks.
I have a text field, in the format 1/1/2009.
I would like to change this to Date/Time so I can do proper date sorting and querying. I get a message indicating there is not enough memory space.
Please offer how I may alleviate this problem?
Thanks.
ASKER
Ok, I have used CDATE already in the first source file, where the date field was listed in the Text form:
2008-07-23 00:00:00
I use the formula:
CDATE(Left([Original Service Date],10))
and this leaves the date looking like:
7/23/2008 as a Text
I know want to convert this to Date/Time.
I attempted your suggestion above, but this did not change the format to Date/Time
Thanks.
2008-07-23 00:00:00
I use the formula:
CDATE(Left([Original Service Date],10))
and this leaves the date looking like:
7/23/2008 as a Text
I know want to convert this to Date/Time.
I attempted your suggestion above, but this did not change the format to Date/Time
Thanks.
"I know want to convert this to Date/Time."
That's what CDate() does. It my 'look' like 'text', but it's been converted to a real Date/Time data type:
From the Help File:
Function Return Type Range For Expression Argument
CDate Date Any valid date expression.
mx
That's what CDate() does. It my 'look' like 'text', but it's been converted to a real Date/Time data type:
From the Help File:
Function Return Type Range For Expression Argument
CDate Date Any valid date expression.
mx
Where are you using this ?
mx
mx
ASKER
Not sure what you mean by "Where"
I run an update query, using CDATE.
If the field has been changed to Date/Time, then why in Design viwe of the table does it still indicate Text. Also, when I sort, it does not sort chronologically...that is 1/1/2009 appears before 10/31/2008.
Thanks.
I run an update query, using CDATE.
If the field has been changed to Date/Time, then why in Design viwe of the table does it still indicate Text. Also, when I sort, it does not sort chronologically...that is 1/1/2009 appears before 10/31/2008.
Thanks.
ohhh ... well, that function is not going to change the *design* of the table, only the data type on the fly.
Can you make the change from Text to Date/Time in the table design for that field?
mx
Can you make the change from Text to Date/Time in the table design for that field?
mx
ASKER
No, I cannot, I run out of memory. The original table has over 165K records
Please find one sample row attached with all information removed except the field with the date in Text format.
Please find one sample row attached with all information removed except the field with the date in Text format.
ASKER
The file is not uploading. Sorry
Standby .. I will give you another way to change the data type w/o opening in design view.
mx
mx
ASKER
Truly appreciated...thanks!
ok .... execute this line of code from the VBA Immediate window ... but first:
Make a backup.
Be sure the table is not open or in use.
Change the table and field names accordingly.
From the Immediate window (note - do not put a ? in front of this - like you sometimes do)
CurrentDb.Execute "ALTER TABLE [" & "YourTableName" & "] ALTER COLUMN " & "YourFieldName" & " DATE"
mx
Make a backup.
Be sure the table is not open or in use.
Change the table and field names accordingly.
From the Immediate window (note - do not put a ? in front of this - like you sometimes do)
CurrentDb.Execute "ALTER TABLE [" & "YourTableName" & "] ALTER COLUMN " & "YourFieldName" & " DATE"
mx
ASKER
Yes, you know me...
I have created a form, with the button to launch the code (not sure waht you mean by immediate window). I get an error 3293 message on the line beginning with CurrentDb.
Private Sub Command0_Click()
CurrentDb.Execute "ALTER TABLE [" & "B" & "] ALTER COLUMN " & "Original Service Date" & " DATE"
End Sub
Thanks
I have created a form, with the button to launch the code (not sure waht you mean by immediate window). I get an error 3293 message on the line beginning with CurrentDb.
Private Sub Command0_Click()
CurrentDb.Execute "ALTER TABLE [" & "B" & "] ALTER COLUMN " & "Original Service Date" & " DATE"
End Sub
Thanks
ASKER
Will CAST work on a field? I will look into this as well.
Thanks.
Thanks.
ok ... the field name has spaces ... try this:
CurrentDb.Execute "ALTER TABLE [" & "B" & "] ALTER COLUMN [" & "Original Service Date" & "] DATE"
added brackets .......................... .......... .......... .......... .......... .......... .^ .......................... .......... .......... ^
mx
CurrentDb.Execute "ALTER TABLE [" & "B" & "] ALTER COLUMN [" & "Original Service Date" & "] DATE"
added brackets ..........................
mx
CAST is not supported in Access.
mx
mx
ASKER
Now, I get the error System Resources Executed - Run-Time Error
wow. Well, can you reboot ... don't open any other apps, then try this?
If not ... can you uploaded the backend ... Compact and Repair first, then zip it up.
In fact, do a Compact and Repair and then run it again.
mx
If not ... can you uploaded the backend ... Compact and Repair first, then zip it up.
In fact, do a Compact and Repair and then run it again.
mx
ASKER
Yes, I am compact and repairing. Our computers are now configured so we log-off, we do not restart, and system maintenance does what it needs to every evening.
I know I could just also hit the on/off switch, and will try this as well.
Thanks.
I know I could just also hit the on/off switch, and will try this as well.
Thanks.
ASKER
Still get error 3035 - System resources. It is a large table - about 165K
Thanks.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Actually, is this a local table or a linked table on the server ??
mx
mx
ASKER
I restarted my computed, still no luck.
ASKER
This is a local table.
I am now working on the suggestion of copying the Text field, but already know I will get a lack of memory error (this has happened before)
I am now working on the suggestion of copying the Text field, but already know I will get a lack of memory error (this has happened before)
See my last two posts above.
mx
mx
ASKER
I tried your suggestion.
Created an update query, after a new Date/Time field was created. In the update to space under the newly created field, I entered "Original Service Date" and ran the update query.
No records were updated.
Thanks.
Created an update query, after a new Date/Time field was created. In the update to space under the newly created field, I entered "Original Service Date" and ran the update query.
No records were updated.
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I do not mind leaving the field as Text, as long as I am sort as if it were a date, but in Text format, Access does not read it this way.
Thanks.
Thanks.
ASKER
Thanks.
So, you got it to work?
mx
mx
ASKER
Yes, I have tried the Update query before...but it never worked due to lack of memory space, so I did not even think of doing an update query again.
We recently re-installed all applications on my computer, so this may have had something to do with it.
Thanks again for everything.
We recently re-installed all applications on my computer, so this may have had something to do with it.
Thanks again for everything.
You are welcome.
mx
mx
ASKER
You are all the best...be well.
CDate(YourTextField)
mx