ASP Forum
C# Date Math
stimpy | Posted 2:18pm 7. August 2008 Server Time |

It's been a long time since I've had to do any date math cany anyone help. I need to determine if Date A is 6 months or older than Date B.
mp3cdman | Posted 4:28pm 9. August 2008 Server Time |

I'm sure Informant will tell us all that there is a better way but i'd do something like..

if (System.DateTime.Compare(dtA.AddMonths(6), dtB) > 0) {

}

where dtA and dtB are dates A and B respectively...

mp3cdman ;-P
mp3cdman | Posted 2:40am 11. August 2008 Server Time |

oops just re-read and my code would only check for more than 6 months...

just change it to

if (System.DateTime.Compare(dtA.AddMonths(6), dtB) >= 0) {

}

mp3cdman ;-P


Reply to Post C# Date Math



Back to Forum Page