Solved

c# Help Comparining DateTimes

Posted on 2009-07-08
1
241 Views
Last Modified: 2012-05-07
I need to check a DateTime variable and evaluate whether it is more than a day older then the current datetime.

Any ideas on how to accomplish this.
0
Comment
Question by:Prysson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
mysteriousguy earned 500 total points
ID: 24806500
Simply substract the two DateTimes and evaluate if the resulting TimeSpna is greater than one day.
DateTime dateTimeToCheck = new DateTime(2009, 7, 2,7,0,0);
TimeSpan difference = DateTime.Now - dateTimeToCheck;
bool moreThanOneDay = difference > TimeSpan.FromDays(1);
MessageBox.Show(moreThanOneDay ? "true": "false");

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question