Do your arithmetic against the real date--then format the result:
Dim myDate as date
mydate = date - 14
msgbox format(mydate, "yymmdd")
> Hi All,
>
[quoted text clipped - 7 lines]
> Thanks
> Chad

Signature
Dave Peterson
Chad - 12 Oct 2008 16:47 GMT
Thanks Dave, always fast on the replys.
startdate = "0" & enddate - 7 'startdate equals "080999"
x = Format(startdate, "YYMMDD")
x = 211006
Not sure what is happening, but it is wrong. I guess it is thinking my
startdate is a different format that YYMMDD
Chad
> Do your arithmetic against the real date--then format the result:
>
[quoted text clipped - 14 lines]
>> Thanks
>> Chad
Chad - 12 Oct 2008 16:56 GMT
It's not nice, but I broke apart the date and rearranged the numbers so that
the format liked it.
It you know a better way, that would be better.
Chad
x = Right(enddate, 2) & "/" & Mid(enddate, 3, 2) & "/" & Left(enddate, 2)
x = Format(x, "YYMMDD")
> Do your arithmetic against the real date--then format the result:
>
[quoted text clipped - 14 lines]
>> Thanks
>> Chad
Dave Peterson - 12 Oct 2008 18:42 GMT
I don't understand.
I still think you'd be better off just working with the dates--not the formatted
strings.
Is there a reason you can't work with the real date?
> It's not nice, but I broke apart the date and rearranged the numbers so that
> the format liked it.
[quoted text clipped - 27 lines]
> >
> > Dave Peterson

Signature
Dave Peterson
Chad - 12 Oct 2008 23:20 GMT
My computer's default date style is DD/MM/YYYY, but the text in the file I
am working with has strings like 081012a (date and a letter to signify
sample batch). So I don't think I can do what you say. Just because the
string is a string and not a date.
>I don't understand.
>
[quoted text clipped - 38 lines]
>> >
>> > Dave Peterson
Dave Peterson - 13 Oct 2008 00:30 GMT
You could extract the date from that string:
dim myVal as string
dim myDate as date
myval = "081012a"
'does 081012 represent Oct 12, 2008?
mydate = dateserial(2000+left(myval,2),mid(myval,3,2),mid(myval,5,2))
'Then you can use:
mydate = mydate - 14
'And display it anyway you want:
msgbox format(mydate,"yymmdd")
> My computer's default date style is DD/MM/YYYY, but the text in the file I
> am working with has strings like 081012a (date and a letter to signify
[quoted text clipped - 47 lines]
> >
> > Dave Peterson

Signature
Dave Peterson