Problems in converting date field to text field

Notsogood

Registered User.
Local time
Today, 22:38
Joined
Jan 21, 2004
Messages
86
I have a strange problem of converting a date field stored as dd/mm/yyyy to a text[8] field. Example 01/06/1947 should be converted to 01061947. What is the easiest way of doing it? I tried changing it to first to ddmmyyyy and then change it to text, but it did not work.Can someone help me please?
Many thanks,
 
Try the DatePart function to extract the month,day,year then
concatenate them into a string.
 
Please can you give me the steps for that, I am not sure I understand the instructions.
Thanks again
 
I tried changing it to first to ddmmyyyy and then change it to text, but it did not work.
What didn't work? Did you get an error? Did you use the format() function? What are you doing with the "Text" field?
 
This is an example of how you will concatenate date parts into a string:
(Assuming you have a form with a date field called "txtDate" and another control called "txtToday")

Me.txtToday= DatePart("d",Me.txtDate) & DatePart("m",Me.txtDate) & DatePart("yyyy",Me.txtDate)

Try adopting this code to your own requirements.
 
Neil -

What exactly are you trying to do? Going from a valid date/time field to a hacked-up text field. That's outrageous! and you might want to take a look at your logic.

So, having said that:

'a date in US short-date format
'e.g.: 1 June 1947
x = #06/01/1947#
'ensure it's actually a date as stored internally by Access
? cdbl(x)
17319

'convert it to a text field in dd/mm/yyyy format
y = format(x, "dd/mm/yyyy")
? y
01/06/1947
? cdbl(y)

runtime error '13'
? y
01/06/1947

So, as you can see, it's no longer a valid date/time field and you've got yourself a big old piece of shit.

Eh?

Bob
 

Users who are viewing this thread

Back
Top Bottom