Solved

Date Issues

Posted on 2001-06-11
8
140 Views
Last Modified: 2012-03-15
Hello!

My name is Assaf Lasry and I am a junior programmer. I have a small problem with dates. I am building an application that registers members, and the membership expires on August 31 of every year (31/08/xxxx), REGARDLESS when did the person registered. Example, if I registered on november 23 2001 (23/11/2001), my registration expires on August 31 2002 (31/08/2002). Another example, if I registered on August 30 2001 (30/08/2001), my registration will expire on august 31 2001 (31/08/2001). I want to create a form where I have 2 text boxes. One text boxe will show the current date, and the other will show August 31 of the PREVIOUS year. Example, if today we are June 11 2001 (11/06/2001), the other text box has to show August 31 2000 (31/08/2000).

What can I do in order to achieve that? Please I need help.

Thank you in advance,
Assaf Lasry.
0
Comment
Question by:AssafL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Accepted Solution

by:
ShaneCourtrille earned 100 total points
ID: 6178885
Are you using a DateTime Picker control?  This would probably be preferable to the textbox and it comes with Visual Basic (at least in 6 it does).

If you're just using a textbox..

Dim myDate As Date
Dim myDate2 As Date

myDate = Format(Text1.Text, "mm/dd/yyyy") ' Get the original date

myDate = myDate - 356 ' Minus a year

myDate2 = "31/08/" + Format(myDate, "yyyy") ' Get the new date

Text2.Text = myDate2 ' Write it out

0
 
LVL 1

Expert Comment

by:ShaneCourtrille
ID: 6178891
PS If you wanted to switch to a DateTime picker control all you'd need to do is use switch anywhere you see
Text1.Text to DTPicker1.Value same thing with Text2.Text to DTPicker2.Value.
0
 
LVL 4

Expert Comment

by:beckingh
ID: 6178895

txtToday.text = format(now(), "DD/MM/YYYY")
txtLastYear.text = "31/08/" & cstr(year(now()) - 1)

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 38

Expert Comment

by:PaulHews
ID: 6178896
Private Sub Command1_Click()
    Text1 = Format(Date, "short date")
    If Date < DateSerial(Year(Date), 8, 31) Then
        Text2 = Format(DateSerial(Year(Date) - 1, 8, 31), "short date")
    Else
        Text2 = Format(DateSerial(Year(Date), 8, 31), "short date")
    End If
End Sub
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6178949
>One text boxe will show the current date, and the other will show August 31 of the PREVIOUS year.

My example will show the past expiration date.  Not sure if that is what you needed.  Otherwise you could just use:


Text2 = Format(DateSerial(Year(Date) - 1, 8, 31), "short date")

to show the Aug 31 date of the previous calendar year.
0
 
LVL 3

Expert Comment

by:Hornet241
ID: 6179380
Try this, you can format the date results how you want.

Text1.Text = Date

Text2.text = DateAdd("yyyy", -1, Date)
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7135901
Hi AssafL,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept ShaneCourtrille@idg's comment(s) as an answer.
*** The FIRST correct answer to this simple Q

AssafL, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7168341
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question