Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 11th, 2005, 10:25 PM
Authorized User
 
Join Date: Aug 2004
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Default Find months difference

Hello,

  How can i get the exact months difference between two dates. I tried this


dim dt1,dt2
dt1=#3-Jan-2005#
dt2=#1-Feb-2005#
response.write datediff("d",dt1,dt2)


Its still displaying 1. Actually its not 1.

datediff will find based on the months in the two dates.
Event the dt1 is #31-Jan-2005#, it displays 1.

??????


 
Old February 12th, 2005, 01:51 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

ii believe you have to change this line:

response.write datediff("d",dt1,dt2)

to

response.write datediff("m",dt1,dt2)
 
Old February 12th, 2005, 04:41 AM
Authorized User
 
Join Date: Aug 2004
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,

  Thanx for the reply. I mistakened here. Actually it is "m" only.

Any sollution???

 
Old February 12th, 2005, 01:13 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what do you mean by *exact months difference*?

<%
Date1 = #01/01/2005#
Date2 = #02/01/2005#

MonthDiff = DATEDIFF("M",Date1,Date2)

Response.Write(MonthDiff)
%>
This shold return 1, what's problem? are you saying that
If Date1 = 01/01/2005 and Date2=01/15/2005 then monthdiff should be about 0.48

 
Old February 14th, 2005, 08:36 PM
Authorized User
 
Join Date: Aug 2004
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No,

  Suppose the first date is 25-Jan-05
and the second date is 1-feb-05

If i want to find the months diff between these two,

  it gives 1. But actually it is less then 31 days(jan 31) it should return 0 instead of 1. If the second date is 10-mar-05,
it should return 1 only(not 1.x).

i think u got it.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Find difference between table and updated table jasemhi Access 2 September 20th, 2008 04:25 PM
display all dates within months sanjeev jha Classic ASP Basics 1 June 6th, 2008 12:46 PM
T-SQL Code to get last 6 months midway11 SQL Language 1 October 15th, 2006 08:59 AM
Years to Months Conversion mahajanvit ASP.NET 2.0 Basics 2 September 25th, 2006 11:43 PM
find time difference? possible using Asp? blueguy Classic ASP Basics 5 January 23rd, 2006 04:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.