🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.comp.lang.visualbasic.ver3
7 messages
7 total messages Started by Sebastien Thibault Wed, 16 Aug 2000 04:01
Comparing date
#62
Author: Sebastien Thibault
Date: Wed, 16 Aug 2000 04:01
13 lines
1437 bytes
How do I do to compare 2 date togeter like

If Date1 < Date2 Then
    Print "Date1 is smale"
Else
    Print "Date2 is smale"
End If

What is the function to compare date in Visual Basic?

Thanks

S�bastien
Re: Comparing date
#65
Author: Johan Bechthum
Date: Wed, 16 Aug 2000 00:00
43 lines
2114 bytes
"Sebastien Thibault" <thibauls@videotron.ca> schreef in bericht
news:2kom5.3027$7_5.136777@weber.videotron.net...
| How do I do to compare 2 date togeter like
|
| If Date1 < Date2 Then
|     Print "Date1 is smale"
| Else
|     Print "Date2 is smale"
| End If
|
| What is the function to compare date in Visual Basic?
|
Dim Date1 As Date
Dim Date2 As Date
    Date1 = "08/16/2000 11:00:01"
    Date2 = "08/16/2000 11:00"

    If Int(Date1) < Int(Date2) Then
        MsgBox "Date1 is earlier then Date2"
    ElseIf Int(Date1) = Int(Date2) Then
        MsgBox "Date1 is eaqual to Date2"
    Else
        MsgBox "Date1 is later then Date2"
    End If

pops up the box with "Date1 is eaqual to Date2"

BUT

    If Date1 < Date2 Then
        MsgBox "Date1 is earlier then Date2"
    ElseIf Date1 = Date2 Then
        MsgBox "Date1 is eaqual to Date2"
    Else
        MsgBox "Date1 is later then Date2"
    End If

pops up the box with "Date1 is later then Date2"

So it depents what you want to compare, only the date reguardless the time,
or the exact date and time.

Johan.
Re: Comparing date
#66
Author: David May
Date: Wed, 16 Aug 2000 00:00
24 lines
1318 bytes
Sebastien

Your code will work as written if you specify date1 and date2 as date
datatypes - possibly using the cvdate function to ensure that entered
dates are converted to dates correctly.

Regards
David

Sebastien Thibault wrote:
> 
> How do I do to compare 2 date togeter like
> 
> If Date1 < Date2 Then
>     Print "Date1 is smale"
> Else
>     Print "Date2 is smale"
> End If
> 
> What is the function to compare date in Visual Basic?
> 
> Thanks
> 
> S�bastien
Re: Comparing date
#63
Author: Larry Linson
Date: Wed, 16 Aug 2000 04:42
43 lines
2453 bytes
In article <2kom5.3027$7_5.136777@weber.videotron.net>,
  "Sebastien Thibault" <thibauls@videotron.ca> wrote:
 > How do I do to compare 2 date togeter like
 >
 > If Date1 < Date2 Then
 >     Print "Date1 is smale"
 > Else
 >     Print "Date2 is smale"
 > End If
 >
 > What is the function to compare date in Visual Basic?

The following

  Public Function WhichIsIt(pdatFirst As Date, pdatSecond As Date) As
String

    If pdatFirst < pdatSecond Then
        WhichIsIt = "First " & pdatFirst & " is smaller"
    Else
        WhichIsIt = "First " & pdatFirst & " is equal or greater"
    End If

  End Function

when run from the Immediate Window, gave

  ? WhichIsIt(#12/31/1999#,#4/15/2000#)
   First 12/31/99 is smaller
  ? WhichIsIt(#01/01/2001#,#02/02/1902#)
   First 1/1/01 is equal or greater

and that looks OK to me, given that it was a very limited test.

--
 L. M. (Larry) Linson
  http://www.ntpcug.org - North Texas PC User Group - Visit and Join
  http://www.ntmsdevsigs.homestead.com - NTPCUG Developer SIGs
  http://homestead.deja.com/user.accdevel - Access examples


Sent via Deja.com http://www.deja.com/
Before you buy.
Re: Comparing date
#64
Author: chas
Date: Wed, 16 Aug 2000 06:48
1 lines
1384 bytes
Try arranging the dates as yyyymmdd and do a normal numeric comparison
Re: Comparing date
#60
Author: UCT STUDENT
Date: Mon, 21 Aug 2000 00:00
23 lines
1458 bytes
The easiest way to do this is use the VB6 DateTimePicker control

IF DTPicker1.Value < DTPicker2.value then etc etc et

Hope it helps
Alan


Sebastien Thibault wrote:

> How do I do to compare 2 date togeter like
>
> If Date1 < Date2 Then
>     Print "Date1 is smale"
> Else
>     Print "Date2 is smale"
> End If
>
> What is the function to compare date in Visual Basic?
>
> Thanks
>
> S�bastien
Re: Comparing date
#61
Author: Dan
Date: Mon, 21 Aug 2000 00:00
29 lines
1526 bytes
MS's suggested method for comparing dates is DateDiff

On Mon, 21 Aug 2000 12:32:20 +0200, UCT STUDENT
<BLLALA005@mail.uct.ac.za> wrote:

>The easiest way to do this is use the VB6 DateTimePicker control
>
>IF DTPicker1.Value < DTPicker2.value then etc etc et
>
>Hope it helps
>Alan
>
>
>Sebastien Thibault wrote:
>
>> How do I do to compare 2 date togeter like
>>
>> If Date1 < Date2 Then
>>     Print "Date1 is smale"
>> Else
>>     Print "Date2 is smale"
>> End If
>>
>> What is the function to compare date in Visual Basic?
>>
>> Thanks
>>
>> S�bastien
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads