473,830 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Steve
<co*****@gmail. comwrote in message
news:de******** *************** ***********@y21 g2000hsf.google groups.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...@nomse nse.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******** *************** ***********@y21 g2000hsf.google groups.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******** *************** ***********@y21 g2000hsf.google groups.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.go oglegroups.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...@nomse nse.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:dedc379 8-64a6-4e78-a7f9-99b5ed08d388
@y21g2000hsf.go oglegroups
>.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
32432
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 query to format the date returned as a timestamp without having to do the conversion in php. Can someone tell me what to put in my db query?
3
3746
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 function 1) parsedate function failed if a date string like below format "16-MAY-2005 01:26" 2)parsedate_tz function also failed if a date string
5
16095
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 this to Hijri to gregorian it either do nothing or go to next record on form. well there r two fields on form that r calc afterevents each other dates. ur assistance will be highly appreciated, if any one can tell what is wrong with this codes
1
3606
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 it works. I never get errors, and if I don't try to update the date fields, I always update the expected number of rows (1). When I do date conversion using the same conversion function, then call CRowset::Add() to add a record to the same table,...
5
8651
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 when the date state is not valid. But we may need to pass NULL dates (read from a database) to our COM clients! - Yes, this problem doesn't occur in Release version, but we can't have a Debug version that asserts from time to time :) A solution...
29
9157
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 example is: 36,525 represents 01/01/1900. The starting point date is considered to be : 00/00/0000. I have looked thru Help and used Google and have not really found an answer. I know that Leap Years need to be accounted for too. Any...
10
1684
by: melissa.nava | last post by:
Here is my code: ***** Public Property DOB() As Date Get Try DOB = (msBirthMonth + "/" + msBirthDay + "/" + msBirthYear)
1
5945
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 address varchar phoneno int date varchar i want the record of students between 1-1-2006 and 1-2-2006 as my field name type of date is varchar i...
44
10248
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
5157
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 doesn't generate any error, this is what I am doing: --------------------------- Dim strSDate As String Dim strSTime As String Dim strStartDT As String Dim strSDateTime As String
0
9793
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10489
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10525
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10202
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7746
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6950
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.