473,472 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to test whether date is today

lee123
556 Contributor
how do i change this code to do dates instead if time:

Expand|Select|Wrap|Line Numbers
  1.   CurrentTime = Format(Time, "hh:mm")
  2.     If CurrentTime = txtBillTime.Text Then
  3.         Beep
  4.         frmAppointment.WindowState = 0 'Restore form
  5.     End If
lee123
Dec 26 '07 #1
19 2110
VijaySofist
107 New Member
Hi!

I think this is the one you looked for

Code: ( text )

1. CurrentDate = Format(Date, "dd-MM-yyyy")
2. If CurrentDate = Format(txtBillDate.Text,"dd-MM-yyyy") Then
3. Beep
4. frmAppointment.WindowState = 0 'Restore form
5. End If


If the above is not the code you looked for means, Can you please explain clearly.


All the Best

With Regards
Vijay. R
Dec 26 '07 #2
debasisdas
8,127 Recognized Expert Expert
If you want date why passing time ?

Instead of passing time ,you need to pass date.
Dec 26 '07 #3
lee123
556 Contributor
Debasisdas,
i stumbled on to this code for a project im doing. and the way they did this it only had time. but i wanted something with dates. so when that date hit it would pop up the form (a reminder)

thanks vijaysofist i'll try this and see if it works.

lee123
Dec 26 '07 #4
lee123
556 Contributor
hey vijaysofist,

i found this code in a book i have because it deals with something i've been trying to do but it only has the time i wanted it for the date. so i can set it and when the date hit it would pop up the message i typed in the form like a reminder the whole code to this is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSetTime_Click()    
  2.     frmAppointment.WindowState = 1  ('this is to set the form to close to the task bar)
  3.     Timer1.Enabled = True  
  4. End Sub
then in the timer i have this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer1_Timer()
  2.     On Error Resume Next
  3.    CurrentDate = Format(Date, "mm-dd-yy")
  4.     If CurrentDate = Format(Txtbilldate, "mm-dd-yy") Then
  5.         Beep
  6.         frmAppointment.WindowState = 0 'Restore form
  7.     End If
  8. End Sub
I wanted this code to do dates so i can enter in a date so when the date came it would remind me of a task or appointment. but i tried your code and the form doesn't close to the taskbar it keeps popping back up when i try to set the date


lee123
Dec 26 '07 #5
lee123
556 Contributor
i have posted a reply but it never shows up
Dec 26 '07 #6
lee123
556 Contributor
hi there i have been posting posts but they don't show up anyway

to vijaysofist,

i have tried your code but it doesn't work the whole code i have in my form is this. in the button to (set the date):
Expand|Select|Wrap|Line Numbers
  1. Private Sub SetDate_Click()
  2.     On Error Resume Next
  3.     frmAppointment.WindowState = 1
  4.     Timer1.Enabled = True  'Start timer
  5. End Sub
and for the timer i have this now.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer1_Timer()
  2.     On Error Resume Next
  3.    CurrentDate = Format(Date, "mm/dd/yy")
  4.     If CurrentDate = Format(Txtbilldate, "MM/DD/YY") Then
  5.         Beep
  6.         Timer1.Enabled = False
  7.         frmAppointment.WindowState = 0 'Restore form
  8.     End If
  9. End Sub
  10.  
but the whole thing is suppose to be a (reminder form) that pops up when you set the date you want to be reminded of a task or appointment. but i can't get it to work right.

to debasisdas:

to answer your question i found this code in a book i have but it deals with the time only and it's similar to what i wanted to do but with dates i wanted to use this code for the project above. by the way what did you mean by this:


Expand|Select|Wrap|Line Numbers
  1. If you want date why passing time ?
  2.  
  3. Instead of passing time ,you need to pass date.
lee123
Dec 27 '07 #7
VijaySofist
107 New Member
hey vijaysofist,

i found this code in a book i have because it deals with something i've been trying to do but it only has the time i wanted it for the date. so i can set it and when the date hit it would pop up the message i typed in the form like a reminder the whole code to this is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSetTime_Click()    
  2.     frmAppointment.WindowState = 1  ('this is to set the form to close to the task bar)
  3.     Timer1.Enabled = True  
  4. End Sub
then in the timer i have this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer1_Timer()
  2.     On Error Resume Next
  3.    CurrentDate = Format(Date, "mm-dd-yy")
  4.     If CurrentDate = Format(Txtbilldate, "mm-dd-yy") Then
  5.         Beep
  6.         frmAppointment.WindowState = 0 'Restore form
  7.     End If
  8. End Sub
I wanted this code to do dates so i can enter in a date so when the date came it would remind me of a task or appointment. but i tried your code and the form doesn't close to the taskbar it keeps popping back up when i try to set the date


lee123


Hi!

So you want your form to close to the taskbar! Right.

Please Look back your code. This is because in the cmdSetTime_Click() Event - you minimized the Form and then Enabled the Timer - where the timer maximizes the form again.

Use
---------------
frmAppointment.WindowState = 0 'in the cmdSetTime_Click() Event

and Use
--------------
frmAppointment.WindowState = 1 'in the Timer1_Timer() Event

Please get back to me, whether it works for you or not.


All the Best

With Regards
Vijay. R
Dec 27 '07 #8
VijaySofist
107 New Member
Hi!

Check whether if you are using a text box named Txtbilldate to get the date.

Check it and reply My Friend!


With Regards
Vijay. R
Dec 27 '07 #9
9815402440
180 New Member
hi
replace line
If CurrentDate = Format(Txtbilldate, "MM/DD/YY") Then
with following line

If datediff("d",format(CurrentDate,"mm/dd/yy") , Format(Txtbilldate, "MM/DD/YY"))=0 Then

because using CurrentDate = Format(Txtbilldate, "MM/DD/YY") you are comparing two strings not two dates.

regards
manpreet singh dhillon hoshiarpur
Dec 27 '07 #10
debasisdas
8,127 Recognized Expert Expert
Let me know do you still have the problem.

Do not start another thread just to reply to another .

Please continue in the same thread only.

Both tthe threads are merged for better management of the forum.
Dec 27 '07 #11
daniel aristidou
491 Contributor
hi
replace line
If CurrentDate = Format(Txtbilldate, "MM/DD/YY") Then
with following line

If datediff("d",format(CurrentDate,"mm/dd/yy") , Format(Txtbilldate, "MM/DD/YY"))=0 Then

because using CurrentDate = Format(Txtbilldate, "MM/DD/YY") you are comparing two strings not two dates.
You can also try the Cdate method
ie
Expand|Select|Wrap|Line Numbers
  1. if Cdate(date) = Cdate(Txtbilldate) then
ect
The reson other attemps did not work is because you comparing
dates such as 12/1/2007 with 3/3/2008

12/#/#### is greater than 3/#/###
What you should of done is

Formatdate(txtbilldate,"YYYYMMDD")
Dec 27 '07 #12
lee123
556 Contributor
do i still set the timer intervals at 1000?

lee123
Dec 28 '07 #13
lee123
556 Contributor
hey thanks it worked but as soon as it hits 12:00 am it beeps. but i was thinking who's up at that time? i thank you guys for all your help. but me not thinking of the problem at hand there's got to be a way to set a time too.

example: 12/28/07 @ 8:00am or something like that. i think i might have to put another textbox on the form for this. right? and use the same code but with the time. or can i merge the code in the code now?

lee123
Dec 28 '07 #14
daniel aristidou
491 Contributor
hey thanks it worked but as soon as it hits 12:00 am it beeps. but i was thinking who's up at that time? i thank you guys for all your help. but me not thinking of the problem at hand there's got to be a way to set a time too.

example: 12/28/07 @ 8:00am or something like that. i think i might have to put another textbox on the form for this. right? and use the same code but with the time. or can i merge the code in the code now?

lee123
use "now" instead of date and use it like this

Note that the case of the letters is important
Expand|Select|Wrap|Line Numbers
  1. if format(Now,"yyyymmddhhMMss") = Format(txtbilldate,"yyyymmddhhMMss")
Also note that you have to type the date and time in the textbox correct or else it will create an error or will simply not format the date and time entered

Enter the time and date in the textbox like this
"28/12/2007 10:42:13"

Also if you dont want to be as precise as seconds change the format to this:
Expand|Select|Wrap|Line Numbers
  1. if format(Now,"yyyymmddhhMM") = Format(txtbilldate,"yyyymmddhhMM")
(note i simply removed the "ss"
If you are gonna use this way you can also enter the date and time in the text box like this "28/12/2007 10:42"

Regards Daniel
Dec 28 '07 #15
lee123
556 Contributor
hey thanks daniel it worked are again thanks to all of you other ones that help out too.


lee123
Dec 28 '07 #16
lee123
556 Contributor
Hey there is there a way to make this form pop up when starting up windows i mean if you have a date and time and a reminder in the textboxes that aren't due for a few days?

lee123
Dec 29 '07 #17
daniel aristidou
491 Contributor
Hey there is there a way to make this form pop up when starting up windows i mean if you have a date and time and a reminder in the textboxes that aren't due for a few days?

lee123
Although there are many ways, and most will tell you to use the windows registry. I advise you to use the windows startup folder since it offers more control.

Since i dont know what kind of program this is it varies on the way i would go about this.

If you want the program to load every time the computer starts up- simply create a shortcut in the windows startup folder(should be located inside the startmenu)
If not i might suggest that you place code inside you form which is something like this when the form loads.
Expand|Select|Wrap|Line Numbers
  1. if not textboxdate = Date then
  2. unload me
  3. End if
There is another way i can think of but rather complicated......let me know if this is what you want. if it isnt ill post the other method using the startup folder.

Using the registry would make things alot more complicated.
Another method occured to me using system service but coding it is beyond me. so i would will post the idea for someoneelse to help figure out if it comes to that. :-)
(+_+)
Regards Daniel
Dec 29 '07 #18
lee123
556 Contributor
well the application i have made is a reminder. lets say you wanted a reminder of a certain date you had to do something then you would enter in the date and time and then when that date and time came the reminder program would pop up but right now it only works if you run the program and go to the (reminder) i have a database in the background saving the time and date in the database so it doesn't erase when you stop the program. if i was to distribute this program to someone else or they bought this from me and they liked the program they would probably want the form to load when they started windows. i mean if they had a date and time already in it.you know? and not have to run the program.( oh just so you know this form, is part of another form i created) but whats the use of this form if you had to run the program evertime. i didn't think this would be so useful especially if you had a million things to do. but it goes with the other forms.

lee123
Dec 29 '07 #19
daniel aristidou
491 Contributor
lets say you wanted a reminder of a certain date you had to do something then you would enter in the date and time and then when that date and time came the reminder program would pop up but right now it only works if you run the program and go to the (reminder) i have a database in the background saving the time and date in the database so it doesn't erase when you stop the program. if i was to distribute this program to someone else or they bought this from me and they liked the program they would probably want the form to load when they started windows. i mean if they had a date and time already in it.you know? and not have to run the program.( oh just so you know this form, is part of another form i created) lee123
OK ...
2 options either a service. or your program will load with no forms visible on windows startup.
The idea is for windows to load and then if the date and time is passed the form to appear.......Correct? Changing it into a service is beyond me...so im sure someone else can help out if thisdoes not work.I believe this way will work though.(~_~)
This is what you do. you copy the program to startup folder.
In vb you add this on the forms for when they load
Expand|Select|Wrap|Line Numbers
  1. private sub Form_Load
  2. Form.visible = False
  3. End sub
However i suggest that you change the code you had previously so that instead of :
Expand|Select|Wrap|Line Numbers
  1. If XXXX=XXXXX then 
You changed it to
Expand|Select|Wrap|Line Numbers
  1. If format(now,"yyyymmddhhMM") >= format(XXXXX,"yyyymmddhhMM") then
  2. <Your form>.Show (1)
This will have to be done due to the fact that you maystartup you computer after the date has passed.
I can see a bug in this though. Question do you have a command button on the message form which shuts the program?
If not i suggest you do.This will stop the message form being made modal over and over again.
Daniel (~_~) Happy new year
Dec 31 '07 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Eric Linders | last post by:
Hello, Today is Thursday, August 18, 2004. I would like to have a variable that stores the date this coming Sunday (even if today happened to be Sunday) in YYY-MM-DD format. I also need a...
2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
38
by: | last post by:
I have a script... ----- <SCRIPT language="JavaScript" type="text/javascript"> <!-- function makeArray() { for (i = 0; i<makeArray.arguments.length; i++) this = makeArray.arguments; } ...
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
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,...
1
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...
0
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.