Help with dates

aftershokk

Registered User.
Local time
Today, 23:09
Joined
Sep 5, 2001
Messages
259
I capture last change date on a form using now().
When I export the file my vendor wants the date to be a text field and 8 bytes in length. It has to fill 8 bytes like this - YYYYMMDD


Example in my form - 3/1/2007 8:11:55 AM

I need to convert this to text - 20070301 when I export my file.

thanks!
 
Use a query. Apply the format you want using a calculated field. For example

NewDate:Year([ChangeDate])&Month([ChangeDate])&Day([ChangeDate])

If you just format the column in the query, the data will be exported in its underlying form.
 
From the Immediate window:
?Format(#3/1/2007 8:11:55 AM#,"YYYYMMDD")
20070301
 
Need more help

To expand this:

I want my last change date to be copied into my text date 8 bytes via a macro which I know how to do in my form.

I formatted the text date in the form field as yyyymmdd but I keep getting an error stating that my field needs more bytes to accept the data?

Even though I format the field to 8 bytes it does not copy 8 bytes.

thanks
 
That doesn't make sense. You've got three of the same answer explaining exactly how to do it. What data type are you trying to paste into? It sounds like you're trying to paste into a date field, an integer field, or some other type that will not accept an eight byte numeric string.
 
I formatted the text date in the form field as yyyymmdd
How?
I believe that Format is merely a way of displaying what is still a date field, I think that you must use the approach suggested by Neileg, but you will need to add formatting for Day and Month eg Format(Day(yourfield),"00") to take care of single number values.

Brian
 
Last edited:
answer

I am tring to paste into a text field 8 bytes. The text box is formatted as yyyymmdd.

I even formatted last change date to yyyymmdd and it still does not work.
 
Brian is correct in saying that Neil is correct. You have to change the content of the date field and not just how it is displayed. I can have the number 1234567890 and format it to be (123)456-7890. But it's still stored as 1234567890.

Formatting is just how it is displayed, not how it is stored. Here's what Neil said and what is correct:

NewDate:Year([ChangeDate])&Month([ChangeDate])&Day([ChangeDate])

That not only changes the format, it changes the content, which is what you will need to do.

FYI, there's no need to limit to an eight byte text field. Leave the text field at 255. If you only use 8 bytes, it will only store 8 bytes, and it will not keep the other 247 as blanks.
 
I was just trying to show Neil and the others that this code would work.
NewDate:Format([ChangeDate],"YYYYMMDD")
rather than the more complex:
NewDate:Year([ChangeDate])&Month([ChangeDate])&Day([ChangeDate])
The output of the Format() command is a string.
 
Thanks, RG, I understand. I had forgotten that you can set just about any date format using Format(), probably because I have an aversion to using any date format other than the normal one for the country/region!
 

Users who are viewing this thread

Back
Top Bottom