Connecting Tech Pros Worldwide Forums | Help | Site Map

Date Conversion Problem

Greg (codepug@gmail.com)
Guest
 
Posts: n/a
#1: Aug 15 '08
I have a text box with the date "08/14/2008" in it. I want to press a
button and automatically
calculate and place the date 1-year before in another text box. Result
"08/12/2007".

How do I convert (Date) "08/14/2008" to "08/14/2007" as a legitimate
date, not a text string???

I tried this but I'm getting a string, not a proper date value:
txtStartDate = Month(Date) & " " & Day(Date) & " " & Year(Date) + 1



Greg

Steve
Guest
 
Posts: n/a
#2: Aug 15 '08

re: Date Conversion Problem


Look at the DateAdd function in the Help file. You would subtract one year
from Date().

Steve


<codepug@gmail.comwrote in message
news:dedc3798-64a6-4e78-a7f9-99b5ed08d388@y21g2000hsf.googlegroups.com...
Quote:
>I have a text box with the date "08/14/2008" in it. I want to press a
button and automatically
calculate and place the date 1-year before in another text box. Result
"08/12/2007".
>
How do I convert (Date) "08/14/2008" to "08/14/2007" as a legitimate
date, not a text string???
>
I tried this but I'm getting a string, not a proper date value:
txtStartDate = Month(Date) & " " & Day(Date) & " " & Year(Date) + 1
>
>
>
Greg

Greg (codepug@gmail.com)
Guest
 
Posts: n/a
#3: Aug 15 '08

re: Date Conversion Problem


Thanks Steve

I just discovered it, and this seems to work:
txtStartDate = DateAdd("m", -12, Date)

Thanks
greg



On Aug 14, 7:10*pm, "Steve" <nonse...@nomsense.comwrote:
Quote:
Look at the DateAdd function in the Help file. You would subtract one year
from Date().
>
Steve
>
<code...@gmail.comwrote in message
>
news:dedc3798-64a6-4e78-a7f9-99b5ed08d388@y21g2000hsf.googlegroups.com...
>
>
>
Quote:
I have a text box with the date "08/14/2008" in it. I want to press a
button and automatically
calculate and place the date 1-year before in another text box. Result
"08/12/2007".
>
Quote:
How do I convert (Date) "08/14/2008" to "08/14/2007" as a legitimate
date, not a text string???
>
Quote:
I tried this but I'm getting a string, not a proper date value:
txtStartDate = Month(Date) & " " & Day(Date) & " " & Year(Date) + 1
>
Quote:
Greg- Hide quoted text -
>
- Show quoted text -
Stuart McCall
Guest
 
Posts: n/a
#4: Aug 15 '08

re: Date Conversion Problem


<codepug@gmail.comwrote in message
news:dedc3798-64a6-4e78-a7f9-99b5ed08d388@y21g2000hsf.googlegroups.com...
Quote:
>I have a text box with the date "08/14/2008" in it. I want to press a
button and automatically
calculate and place the date 1-year before in another text box. Result
"08/12/2007".
>
How do I convert (Date) "08/14/2008" to "08/14/2007" as a legitimate
date, not a text string???
>
I tried this but I'm getting a string, not a proper date value:
txtStartDate = Month(Date) & " " & Day(Date) & " " & Year(Date) + 1
>
>
>
Greg
Me!OtherTextbox = DateAdd("yyyy", -1, "08/14/2008")


Bob Quintal
Guest
 
Posts: n/a
#5: Aug 15 '08

re: Date Conversion Problem


Another approach is to use the dateserial() function

txtStartDate = DateSerial( _
year([date])-1, _
Month([date]), _
day([date]))

If you wanted to make the startdate the first of the month, you'd
just replace the day([date]) with 1.

Q

"Greg (codepug@gmail.com)" <codepug@gmail.comwrote in
news:c9840edc-610a-4299-ae50-41d8ef0c34f4
@k37g2000hsf.googlegroups.co
m:
Quote:
Thanks Steve
>
I just discovered it, and this seems to work:
txtStartDate = DateAdd("m", -12, Date)
>
Thanks
greg
>
>
>
On Aug 14, 7:10*pm, "Steve" <nonse...@nomsense.comwrote:
Quote:
>Look at the DateAdd function in the Help file. You would subtract
>one yea
r
Quote:
>from Date().
>>
>Steve
>>
><code...@gmail.comwrote in message
>>
>news:dedc3798-64a6-4e78-a7f9-99b5ed08d388
@y21g2000hsf.googlegroups
Quote:
Quote:
>.com...
>>
>>
>>
Quote:
>I have a text box with the date "08/14/2008" in it. I want to
>press a
button and automatically
calculate and place the date 1-year before in another text box.
Result "08/12/2007".
>>
Quote:
How do I convert (Date) "08/14/2008" to "08/14/2007" as a
legitimate date, not a text string???
>>
Quote:
I tried this but I'm getting a string, not a proper date value:
txtStartDate = Month(Date) & " " & Day(Date) & " " & Year(Date)
+ 1
>>
Quote:
Greg- Hide quoted text -
>>
>- Show quoted text -
>


--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **
Closed Thread