473,626 Members | 3,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Comparison

This is the code that compares the two dates

If (CalendarDate1 >= CalendarDate2) Then
MsgBox "Please enter the correct date range", vbOKOnly + vbExclamation,
"SASMonitor "
Exit Sub
End If
The below code is where i get the date from the user.i have two calendar
components in my form.that's why two calendar

Private Sub Calendar1_Click ()
CalendarDate1 = Trim(Format(Cal endar1.Value, "dd-mm-yy"))
Command1.Enable d = False
MsgBox CalendarDate1
End Sub
Private Sub Calendar2_Click ()
CalendarDate2 = Trim(Format(Cal endar2.Value, "dd-mm-yy"))
Command1.Enable d = False
Command3.SetFoc us
MsgBox CalendarDate2
End Sub
'when i do this i am not able to get the correct comparison.the case is when
i select 10th may 2004 from the first calendar and 1st june 2004 from the
second calendar,it says that 10th may 2004 is greater.pls help me.
Thanks in advance.
Jul 21 '05 #1
14 2806
Kurien Baker Fenn <Ku************ *@discussions.m icrosoft.com> wrote:
This is the code that compares the two dates

If (CalendarDate1 >= CalendarDate2) Then
MsgBox "Please enter the correct date range", vbOKOnly + vbExclamation,
"SASMonitor "
Exit Sub
End If
The below code is where i get the date from the user.i have two calendar
components in my form.that's why two calendar

Private Sub Calendar1_Click ()
CalendarDate1 = Trim(Format(Cal endar1.Value, "dd-mm-yy"))
Command1.Enable d = False
MsgBox CalendarDate1
End Sub
Private Sub Calendar2_Click ()
CalendarDate2 = Trim(Format(Cal endar2.Value, "dd-mm-yy"))
Command1.Enable d = False
Command3.SetFoc us
MsgBox CalendarDate2
End Sub
'when i do this i am not able to get the correct comparison.the case is when
i select 10th may 2004 from the first calendar and 1st june 2004 from the
second calendar,it says that 10th may 2004 is greater.pls help me.


What are CalendarDate1 and CalendarDate2 declared as? You're using them
as if they're dates at the top, but as strings lower down. You should
get them as DateTimes before doing comparisons.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Kurien Baker Fenn <Ku************ *@discussions.m icrosoft.com> wrote:
This is the code that compares the two dates

If (CalendarDate1 >= CalendarDate2) Then
MsgBox "Please enter the correct date range", vbOKOnly + vbExclamation,
"SASMonitor "
Exit Sub
End If
The below code is where i get the date from the user.i have two calendar
components in my form.that's why two calendar

Private Sub Calendar1_Click ()
CalendarDate1 = Trim(Format(Cal endar1.Value, "dd-mm-yy"))
Command1.Enable d = False
MsgBox CalendarDate1
End Sub
Private Sub Calendar2_Click ()
CalendarDate2 = Trim(Format(Cal endar2.Value, "dd-mm-yy"))
Command1.Enable d = False
Command3.SetFoc us
MsgBox CalendarDate2
End Sub
'when i do this i am not able to get the correct comparison.the case is when
i select 10th may 2004 from the first calendar and 1st june 2004 from the
second calendar,it says that 10th may 2004 is greater.pls help me.


What are CalendarDate1 and CalendarDate2 declared as? You're using them
as if they're dates at the top, but as strings lower down. You should
get them as DateTimes before doing comparisons.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3


"Jon Skeet [C# MVP]" wrote:
Kurien Baker Fenn <Ku************ *@discussions.m icrosoft.com> wrote:
This is the code that compares the two dates

If (CalendarDate1 >= CalendarDate2) Then
MsgBox "Please enter the correct date range", vbOKOnly + vbExclamation,
"SASMonitor "
Exit Sub
End If
The below code is where i get the date from the user.i have two calendar
components in my form.that's why two calendar

Private Sub Calendar1_Click ()
CalendarDate1 = Trim(Format(Cal endar1.Value, "dd-mm-yy"))
Command1.Enable d = False
MsgBox CalendarDate1
End Sub
Private Sub Calendar2_Click ()
CalendarDate2 = Trim(Format(Cal endar2.Value, "dd-mm-yy"))
Command1.Enable d = False
Command3.SetFoc us
MsgBox CalendarDate2
End Sub
'when i do this i am not able to get the correct comparison.the case is when
i select 10th may 2004 from the first calendar and 1st june 2004 from the
second calendar,it says that 10th may 2004 is greater.pls help me.


What are CalendarDate1 and CalendarDate2 declared as? You're using them
as if they're dates at the top, but as strings lower down. You should
get them as DateTimes before doing comparisons.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

i declared Calendardate1 and calendardate2 as dim.so what should i do to
compare.Please help

Thanks in Advance

Jul 21 '05 #4
Kurien Baker Fenn <Ku************ *@discussions.m icrosoft.com> wrote:
i declared Calendardate1 and calendardate2 as dim.so what should i do to
compare.Please help


What do you mean "as dim"?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Do you have option strict on, by the way?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #5


"Jon Skeet [C# MVP]" wrote:
Kurien Baker Fenn <Ku************ *@discussions.m icrosoft.com> wrote:
This is the code that compares the two dates

If (CalendarDate1 >= CalendarDate2) Then
MsgBox "Please enter the correct date range", vbOKOnly + vbExclamation,
"SASMonitor "
Exit Sub
End If
The below code is where i get the date from the user.i have two calendar
components in my form.that's why two calendar

Private Sub Calendar1_Click ()
CalendarDate1 = Trim(Format(Cal endar1.Value, "dd-mm-yy"))
Command1.Enable d = False
MsgBox CalendarDate1
End Sub
Private Sub Calendar2_Click ()
CalendarDate2 = Trim(Format(Cal endar2.Value, "dd-mm-yy"))
Command1.Enable d = False
Command3.SetFoc us
MsgBox CalendarDate2
End Sub
'when i do this i am not able to get the correct comparison.the case is when
i select 10th may 2004 from the first calendar and 1st june 2004 from the
second calendar,it says that 10th may 2004 is greater.pls help me.


What are CalendarDate1 and CalendarDate2 declared as? You're using them
as if they're dates at the top, but as strings lower down. You should
get them as DateTimes before doing comparisons.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

i declared Calendardate1 and calendardate2 as dim.so what should i do to
compare.Please help

Thanks in Advance

Jul 21 '05 #6
Kurien Baker Fenn <Ku************ *@discussions.m icrosoft.com> wrote:
i declared Calendardate1 and calendardate2 as dim.so what should i do to
compare.Please help


What do you mean "as dim"?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Do you have option strict on, by the way?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #7


"Jon Skeet [C# MVP]" wrote:
Kurien Baker Fenn <Ku************ *@discussions.m icrosoft.com> wrote:
i declared Calendardate1 and calendardate2 as dim.so what should i do to
compare.Please help


What do you mean "as dim"?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Do you have option strict on, by the way?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

My platform is visual basics and i have declared it as dim.

Jul 21 '05 #8


"Jon Skeet [C# MVP]" wrote:
Kurien Baker Fenn <Ku************ *@discussions.m icrosoft.com> wrote:
i declared Calendardate1 and calendardate2 as dim.so what should i do to
compare.Please help


What do you mean "as dim"?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Do you have option strict on, by the way?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

My platform is visual basics and i have declared it as dim.

Jul 21 '05 #9
Kurien Baker Fenn <Ku************ *@discussions.m icrosoft.com> wrote:
My platform is visual basics and i have declared it as dim.


No, dim is what you use *to* declare it - have you not specified what
actual type it should be? eg

Dim CalendarDate1 as DateTime

If you don't have option strict on, I strongly recommend that you put
it on.

Again, could you post a short but complete program which demonstrates
the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
13115
by: Donnal Walter | last post by:
I was very surprised to discover that >>> import datetime >>> x = datetime.date(2004, 9, 14) >>> y = datetime.datetime(2004, 9, 14, 6, 43, 15) >>> print x == y True How can these two objects be considered equal? Is there a *general* way to test for date != datetime as well as 4.5 != 4.6?
2
10202
by: Scott Knapp | last post by:
Good Day - I have a form which sets the current date, as follows: <script type="text/javascript"> xx=new Date() dd=xx.getDate() mm=xx.getMonth()+1 yy=xx.getYear() mmddyy=mm+"/"+dd+"/"+yy document.write(mmddyy)
1
2998
by: sylvian stone | last post by:
Hi, I've used standard date functions in the past, but need to create something a little different, as I am working on an investment calculator. What I need to do is validate two dates, and check for a complete years. And a complete year is from day 1 until the proceeding day the following year. A couple of examples:
3
6558
by: Karl Gibbon | last post by:
Hi There, I currently have a database in Access 2002 with several forms. I would like to restrict access to one form in perticular until November 1st every year. My current method (attempted method) is a heavy handed, no nonsense, direct date comparison using VBA. Function NovemberOnwards() 'Use with 'On Avtivate' on Orders form CurrentDate = Date 'I cannot decide which function is best to use
6
8488
by: MarkAurit | last post by:
Im having difficulty coming up with a good algorithm to express the following comparison: "if <a given date> falls between the (current date - 5 days) and the (current date)" Obviously. DateTime.Now and something like (AddDays(DateTime.Now,-5) are used for the inner and outer ranges, its how to express the "between" that has me. /* what Id like to do, in pseudo code */ dateToTest=DateTime.Parse("mm/dd/yy");
3
10220
by: Tiya | last post by:
Hi there !!! I would like to know how to compare dates in javascript. var sdate = new Date(theform.SubmissionDate.value); var odate = new Date(theform.StartDate.value); var todaysdate = new Date(); if(sdate < todaysdate)
4
3748
by: blini | last post by:
Helo.... How I can convert string "26/03/2006 15:51" for a date? I need to convert and to compare if "09/06/2006 14:20" is lesser or equal that the current date. Everything in Javascript.
7
2767
by: mr.nimz | last post by:
hello, this is antenio. recently i've come to a problem. i got a way through it, somehow, still it left me in a curious state, so i'm posting it here, if i can get an answer from some techy, here is my table structure, Name: Table1
3
4037
by: noone | last post by:
Hi, I am designing an application which displays news topics until midnight on the DisplayUntil date and then they should drop out. Unfortunately, they seem to be dropping out at mid-day. I'm storing the 'DisplayFrom' and 'DisplayUntil' dates as SmallDateTime fields so the date is in the format "25/09/2006 00:0:00" and I'm comparing them with GetDate() which (I suspect) includes the actual time as well.
4
7403
by: anagai | last post by:
I just want to check if a date entered in a textbox is equal to the current system date. I set the date object from the input field like this: dt1=new Date('10/01/2007'); the current system date is retrieved like this: curDt = new Date();
0
8268
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
8202
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
8707
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8366
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
8510
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
7199
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
6125
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
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2628
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.