448,969 Members | 1,678 Online
Need help? Post your question and get tips & solutions from a community of 448,969 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
4 Replies

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

 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 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)" Look at the DateAdd function in the Help file. You would subtractone yea r >from Date().Steve.com... >I have a text box with the date "08/14/2008" in it. I want topress 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.