Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date manipulation problem

Status
Not open for further replies.

gsc123

Programmer
Jan 24, 2008
197
Hi

I'm trying to manipulate some dates to give my time left

pStartDate = rsTemp("startDate")
pEndDate = rsTemp("endDate")

both dates from rsTemp are from the db and are date/time data types - on the asp end I what to do soething like this


DateDiff("d",Now(),pEndDate)

I want to return time left? DateDiff just returns a Variant (Long) but I'm not sure how to use it
 
One thing you could try doing is to subtract the 2 values. When you subtract 2 dates, the result is a single representing the number of days. Ex:

Code:
<%
	
	pEndDate = cdate("5/27/2009 8:39:20 PM")
	response.write cDate(pEndDate - Now)
%>

On my server, this displays: 3:34:26 AM

Which means there is 3 hours, 34 minutes, and 26 second until 8:39:20 PM. You'll probably want to play around with the formatting to get it to your liking.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
The problem is I get these dates/times from a database - just entering the date into the cdate function is not an option, its when I try to manipulate the dates is the problem now minus then etc
 
If i say

theTimeLeft = pStartDate - pEndDate

I get values like

9.00009259259241
 
Can you show some typical values you get from the database? Also, what type of database are you using?


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
For the moment I'm using access - values are like thus>

27/05/2009 21:15:50
 
Are you say I have to literally manipulation the date and time string?
 
Surely there must be an easier way than just doing the math on the minutes? or seconds even?

theTimeEnd=DateDiff("n",pStartDate,pEndDate)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top