473,396 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Date Conversion Problem

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 1623
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
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
<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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ben | last post by:
I would like to use php to query a database and retrieve a unix timestamp. The problem is that mysql is storing the data in the date format and not a timestamp. I am sure that I can amend my...
3
by: praba kar | last post by:
Dear All, I have doubt regarding date string to time conversion function. In Python I cannot find flexible date string conversion function like php strtotime. I try to use following type...
5
by: SalimShahzad | last post by:
Dear Respected Gurus, I need a coding assistant converting from gregorian to hijri and vice versa. I have problem with this codes. the problem Gregorian to Hijri gives 100% results. when i enter...
1
by: Riley DeWiley | last post by:
I have an UPDATE query that is always setting 0 records. When I cut and paste the SQL into Access and use it, it fails in the same way unless I coerce the date fields to be '=now()', in which case...
5
by: Paolo | last post by:
We are experiencing a problem with COleDateTime while migrating our MFC&ATL project from VC++6.0 to VC++7.1 (Visual Studio .NET 2003). COleDateTime has a DATE conversion operator that in 7.1 asserts...
29
by: james | last post by:
I have a problem that at first glance seems not that hard to figure out. But, so far, the answer has escaped me. I have an old database file that has the date(s) stored in it as number of days. An...
10
by: melissa.nava | last post by:
Here is my code: ***** Public Property DOB() As Date Get Try DOB = (msBirthMonth + "/" + msBirthDay + "/" + msBirthYear)
1
by: itfgnanvigneshwari | last post by:
hai, as i am new to php field i had a problem in date field. i have table named student with fields fieldname type name varchar...
44
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
2
by: RN1 | last post by:
A TextBox displays the current date (in dd/mm/yyyy format) & time when a user comes to a page (e.g. 15/10/2008 1:36:39 PM). To convert the date into international format so that the remote server...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.