Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 02, 2011 02:38 AM by Damon Liu - MSFT
Member
133 Points
113 Posts
Aug 28, 2011 05:40 AM|LINK
I have a vbp code. i need to verify if a date falls within a specific range:
example:
BDate EDate DescBDate DescEDate Falls within range
10/1/2008 7/31/2009 7/1/2000 3/31/2009 YES
10/1/2008 7/31/2009 4/1/2009 6/30/2010 YES
8/1/2009 10/1/2009 8/1/1994 1/31/2009 NO
7/1/2008 9/30/2008 4/1/2009 6/30/2010 NO
Can someone tell me how to write the logic for the above date range?
Thanks,
Jupi
626 Points
154 Posts
Aug 28, 2011 02:21 PM|LINK
you can handle the datatime variables with the usuall operators greater-than, and less-than
IF dt1 > dt2 THEN dostuff()
Contributor
5920 Points
535 Posts
Microsoft
Sep 02, 2011 02:38 AM|LINK
Hi:
I have writen the logic for you. It isn’t the complete code. And I suppose the data are in a table.
Hope it can help you.
'sjkdlkdfsfdfs
Dim i As Integer
For i = 0 To tb.Row.count - 1
' The BDate insteads of the content in this field.
'And the content should be converted to the type of DateTime
DateTime NewbeginDate=convert.ToDateTime(BDate);
DateTime NewDate=convert.ToDateTime (EDate);
DateTime NewdeBDate=convert.ToDateTime (DescBDate);
DateTime NewdeEDate=convert.ToDateTime (DescEDate);
'range is the content in last field
If (NewDescBDate> NewBDate && NewDescBDate<NewEDate)||(NewDescEDate>NewBDate && NewDescEDate<NewEDate) Then range="Yes"
Else
range = "NO"
Next i
Best Regards, Damon
jojupi01@yah...
Member
133 Points
113 Posts
Date Range Verification - VB question
Aug 28, 2011 05:40 AM|LINK
I have a vbp code. i need to verify if a date falls within a specific range:
example:
BDate EDate DescBDate DescEDate Falls within range
10/1/2008 7/31/2009 7/1/2000 3/31/2009 YES
10/1/2008 7/31/2009 4/1/2009 6/30/2010 YES
8/1/2009 10/1/2009 8/1/1994 1/31/2009 NO
7/1/2008 9/30/2008 4/1/2009 6/30/2010 NO
Can someone tell me how to write the logic for the above date range?
Thanks,
Jupi
vmillasp
Member
626 Points
154 Posts
Re: Date Range Verification - VB question
Aug 28, 2011 02:21 PM|LINK
you can handle the datatime variables with the usuall operators greater-than, and less-than
IF dt1 > dt2 THEN dostuff()
Damon Liu - ...
Contributor
5920 Points
535 Posts
Microsoft
Re: Date Range Verification - VB question
Sep 02, 2011 02:38 AM|LINK
Hi:
I have writen the logic for you. It isn’t the complete code. And I suppose the data are in a table.
Hope it can help you.
'sjkdlkdfsfdfs
Dim i As Integer
For i = 0 To tb.Row.count - 1
' The BDate insteads of the content in this field.
'And the content should be converted to the type of DateTime
DateTime NewbeginDate=convert.ToDateTime(BDate);
DateTime NewDate=convert.ToDateTime (EDate);
DateTime NewdeBDate=convert.ToDateTime (DescBDate);
DateTime NewdeEDate=convert.ToDateTime (DescEDate);
'range is the content in last field
If (NewDescBDate> NewBDate && NewDescBDate<NewEDate)||(NewDescEDate>NewBDate && NewDescEDate<NewEDate) Then range="Yes"
Else
range = "NO"
Next i
Best Regards,
Damon
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework