By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,124 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

Date Conversion Problem

P: n/a
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
Aug 14 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Look at the DateAdd function in the Help file. You would subtract one year
from Date().

Steve
<co*****@gmail.comwrote in message
news:de**********************************@y21g2000 hsf.googlegroups.com...
>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

Aug 14 '08 #2

P: n/a
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:
Look at the DateAdd function in the Help file. You would subtract one year
from Date().

Steve

<code...@gmail.comwrote in message

news:de**********************************@y21g2000 hsf.googlegroups.com...
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- Hide quoted text -

- Show quoted text -
Aug 14 '08 #3

P: n/a
<co*****@gmail.comwrote in message
news:de**********************************@y21g2000 hsf.googlegroups.com...
>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")
Aug 14 '08 #4

P: n/a
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 (co*****@gmail.com)" <co*****@gmail.comwrote in
news:c9840edc-610a-4299-ae50-41d8ef0c34f4
@k37g2000hsf.googlegroups.co
m:
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:
>Look at the DateAdd function in the Help file. You would subtract
one yea
r
>from Date().

Steve

<code...@gmail.comwrote in message

news:dedc3798-64a6-4e78-a7f9-99b5ed08d388
@y21g2000hsf.googlegroups
>.com...
>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- Hide quoted text -

- Show quoted text -


--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **
Aug 15 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.