Solved

Alternate to TimeSpan

Posted on 2009-05-12
5
444 Views
Last Modified: 2012-05-06
I have a date coming from database that I need to display to difference between now and that date. I know that is done with TimeSpan, but is that only way to use TimeSpan or any other way we can use..
lets say date is 5/30/2009 12:00:00 AM comes back from database and I want to see how many days left for my renewing my subscription.
how can I do that without TimeSpan if I can?
0
Comment
Question by:1jaws
[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
5 Comments
 
LVL 18

Expert Comment

by:philipjonathan
ID: 24371371
You can get the number of days from the TimeSpan's Days property ...
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 24371375
This still uses TimeSpan, but it gives you the number of days (would this be sufficient?):
DateTime d1 = "12/01/2009";  //Date from database
 
int days = d1.Subtract(DateTime.Now).Days;

Open in new window

0
 

Author Comment

by:1jaws
ID: 24371378
I have already done that I wonder any other way can be done or do I have to use TimeSpan for sure..
0
 
LVL 9

Assisted Solution

by:tetorvik
tetorvik earned 250 total points
ID: 24371493
Not saying this is advisable, but you can surely do this without TimeSpan.
            DateTime renewalDate = new DateTime(2010, 1, 1);
            int days = Convert.ToInt32((renewalDate.Ticks - DateTime.Now.Ticks) * 1.1574074074074074E-12);

Open in new window

0
 

Author Comment

by:1jaws
ID: 24371496
ok thanks for the advice, I think I will stick with TimeSpan :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 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