msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Date difference and date compare

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
EMILYTAN via VBMonster.co



Joined: 04 Oct 2007
Posts: 2

PostPosted: Wed May 09, 2007 6:49 am    Post subject: Date difference and date compare Reply with quote

1. May i know of the way to compare the dates between 2 dates?
2. I want to find the difference by day between 2 dates...


thank you

--
Message posted via VBMonster.com
http://www.vbmonster.com/Uwe/Forums.aspx/vb-syntax/200705/1

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
MikeD



Joined: 04 Oct 2007
Posts: 3348

PostPosted: Wed May 09, 2007 3:26 am    Post subject: Re: Date difference and date compare Reply with quote

"EMILYTAN via VBMonster.com" wrote in message @uwe...
> 1. May i know of the way to compare the dates between 2 dates?

Look up the DateDiff function in VB's Help.

> 2. I want to find the difference by day between 2 dates...

See answer to #1.

--
Mike
Microsoft MVP Visual Basic
Back to top
View user's profile Send private message
Tony Proctor



Joined: 04 Oct 2007
Posts: 1051

PostPosted: Wed May 09, 2007 1:57 pm    Post subject: Re: Date difference and date compare Reply with quote

1) Use ordinary relational operators, e.g.

Dim dDate1 As Date, dDate2 As Date
dDate1 = #3/25/2007#
dDate2 = #12/25/2007#
Debug.Print (Date >= dDate1 And Date <= dDate2)

2) Use DateDiff function, as Mike said

If things are not working for you, maybe you could show us some example code

Tony Proctor

"EMILYTAN via VBMonster.com" wrote in message@uwe...
> 1. May i know of the way to compare the dates between 2 dates?
> 2. I want to find the difference by day between 2 dates...
>
>
> thank you
>
> --
> Message posted via VBMonster.com
> http://www.vbmonster.com/Uwe/Forums.aspx/vb-syntax/200705/1
>
Back to top
View user's profile Send private message
EMILYTAN via VBMonster.co



Joined: 04 Oct 2007
Posts: 2

PostPosted: Thu May 10, 2007 4:54 am    Post subject: Re: Date difference and date compare Reply with quote

I will try on it first...
Thank you

Tony Proctor wrote:
>1) Use ordinary relational operators, e.g.
>
> Dim dDate1 As Date, dDate2 As Date
> dDate1 = #3/25/2007#
> dDate2 = #12/25/2007#
> Debug.Print (Date >= dDate1 And Date <= dDate2)
>
>2) Use DateDiff function, as Mike said
>
>If things are not working for you, maybe you could show us some example code
>
> Tony Proctor
>
>> 1. May i know of the way to compare the dates between 2 dates?
>> 2. I want to find the difference by day between 2 dates...
>>
>> thank you

--
Message posted via VBMonster.com
http://www.vbmonster.com/Uwe/Forums.aspx/vb-syntax/200705/1

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group