onebite2
asked on
Date time syntax
I am checking for a credit card related clause in vb.net code .Not sure how to check that,looking for syntax
'If the credit card is there for 6 months more than the duedate in that table I need to remove the entry.'
I have a business object which holds all thefields for that table like (Card Expiration date,card create datetime)
'If the credit card is there for 6 months more than the duedate in that table I need to remove the entry.'
I have a business object which holds all thefields for that table like (Card Expiration date,card create datetime)
Hi,
You can use AddMonths to validate it, I am going to assume that when you said "CREDIT CARD IS THER FOR 6 MORE THAN DUEDATE" you mean Credit Card Expiration Date, and that both fields are Date Type, so it will be something like this
If CreditCardExpirationDateFi eld >= DueDate.AddMonths(6) Then
'Remove the Entry
End if
You can use AddMonths to validate it, I am going to assume that when you said "CREDIT CARD IS THER FOR 6 MORE THAN DUEDATE" you mean Credit Card Expiration Date, and that both fields are Date Type, so it will be something like this
If CreditCardExpirationDateFi
'Remove the Entry
End if
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For rawinnlnx9 or wdosanjos' example, you would want to use TotalDays as opposed to Days.
@kaufmed, I think TotalDays would make sense if the calculation involves date and time. If both variables represent just dates, Days should have the same effect.
@wdosanjos
On second thought, I agree. It should have the same effect. I'm so used to working with the seconds/milliseconds members of TimeSpan that I just instinctively applied it here. After reviewing the documentation again, I see that, for the purposes of this question, Days and TotalDays would be equivalent.
The one "flaw" with this logic, though, is that there is an assumption of a flat 180 days equals six months. I think gamarrojgq's approach might be more appropriate here.
On second thought, I agree. It should have the same effect. I'm so used to working with the seconds/milliseconds members of TimeSpan that I just instinctively applied it here. After reviewing the documentation again, I see that, for the purposes of this question, Days and TotalDays would be equivalent.
The one "flaw" with this logic, though, is that there is an assumption of a flat 180 days equals six months. I think gamarrojgq's approach might be more appropriate here.
@kaufmed, I agree with your analysis. @gamarrojgq approach is more flexible as it can address either requirements properly (180 days or 6 months).
Open in new window