Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 11th, 2005, 10:25 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
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.

??????


Reply With Quote
  #2 (permalink)  
Old February 12th, 2005, 01:51 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
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)
Reply With Quote
  #3 (permalink)  
Old February 12th, 2005, 04:41 AM
Authorized User
 
Join Date: Aug 2004
Location: , , .
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???

Reply With Quote
  #4 (permalink)  
Old February 12th, 2005, 01:13 PM
Friend of Wrox
 
Join Date: Jan 2004
Location: , , USA.
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

Reply With Quote
  #5 (permalink)  
Old February 14th, 2005, 08:36 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
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.



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:25 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.