Date Difference

B

bbawa1

Hi,

I have a table which has a field ItemsReceived of type datetime. I
have a grid view which has two columns.


In first column i have to show the data from field ItemsReceived and
in second column I have to show
difference between Currenttime and date from ItemReceived. How can I
do that.


e'g


ItemRecieved Difference
6/13/2007 12:38am 1d 21h 45m
6/13/2007 3:54pm 1d 06h 10m
6/15/2007 12:26pm 34m


So the second coulmn displays the difference of current time minus
ItemRecieved. the format shouild be <mintues>m,
or<hours>h, <mintues>m, or <days>d.


How can I do that.


Thanks in advance
 
M

Masudur

Hi,

I have a table which has a field ItemsReceived of type datetime. I
have a grid view which has two columns.

In first column i have to show the data from field ItemsReceived and
in second column I have to show
difference between Currenttime and date from ItemReceived. How can I
do that.

e'g

ItemRecieved Difference
6/13/2007 12:38am 1d 21h 45m
6/13/2007 3:54pm 1d 06h 10m
6/15/2007 12:26pm 34m

So the second coulmn displays the difference of current time minus
ItemRecieved. the format shouild be <mintues>m,
or<hours>h, <mintues>m, or <days>d.

How can I do that.

Thanks in advance



hi take a look


if (!IsPostBack)
{
Session["JustLoaded"] = DateTime.Now;
}
else
{
Session["PostBacked"] = DateTime.Now;
}

if (Session["JustLoaded"] != null && Session["PostBacked"] !=
null)
{
DateTime one = (DateTime)Session["JustLoaded"];
DateTime two = (DateTime)Session["PostBacked"];
TimeSpan span = two.Subtract(one);
string s = span.Days + "d " + span.Hours + "h " +
span.Minutes+ "m ";
}

see this can be done...
now apply your own technique to solve your problem

Thanks
Masudur
www.kaz.com.bd
http://munnacs.110mb.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top