Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Months between two dates
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Months between two dates

 Post Reply Post Reply Page  <12
Author
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2004 at 9:45am
There isn much to it...just grab the values of i and instert them into db. That's all.
Cristian Banu
Soft 4 web
Back to Top
Maxi View Drop Down
Groupie
Groupie


Joined: 24 October 2002
Location: United Kingdom
Status: Offline
Points: 49
Post Options Post Options   Thanks (0) Thanks(0)   Quote Maxi Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2004 at 10:13am

Hi zaboss

Thanks for trying to help;). Being an amateur I am not sure how to just Grab the values of i and insert them into the DB or Field.

As I wrote in my previous mail, I would have liked to see what results the Function turned out first (make sure that it does it correctly), before I started trying to feed that result to a form field or database.

Kind Regards and thanks again 

maxi

Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2004 at 10:23am

StrLast = DateDiff("m", Request.Form("EndDate"), Request.Form("StartDate"))
StrStart =DatePart("m", Request.Form("StartDate")
StrEnd = DatePart("m", Request.Form("EndDate")

For i = StrStart to StrEnd
Response.Write ""& i &""

If i > StrEnd then Exit for
next

Just add the line in red. Not sure about the number of doublequottes, though... Maybe should be only 1 pair... Sorry, don't have the time right know.

Cristian Banu
Soft 4 web
Back to Top
Maxi View Drop Down
Groupie
Groupie


Joined: 24 October 2002
Location: United Kingdom
Status: Offline
Points: 49
Post Options Post Options   Thanks (0) Thanks(0)   Quote Maxi Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2004 at 11:00am

Hi Zaboss,

I tried your code on a test page and added some dates to see what results came out of it.
Either I am doing something seriously wrong or there is a problem with this script? The answer that was returned to me was 7? I do not know where the 7 comes from as the answer should be: 8,9,10?
Here is the code that I had on the test page.

<%
StrLast = DateDiff("m", 15-10-2003, 15-08-2003)
StrStart = DatePart("m", 15-08-2003)
StrEnd = DatePart("m", 15-10-2003)

For i = StrStart to StrEnd
Response.Write ""& i &""
If i > StrEnd then Exit for
Next
%>

Regards

Maxi:)



Edited by Maxi
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2004 at 11:34am

It seems that there is something wrong with the DatePart function's output... If I changed the date to:

<%
StrLast = DateDiff("m", 15-10-2003, 15-08-2003)
StrStart = DatePart("m", date)
StrEnd = DatePart("m", 10/12/2004)
Response.Write strStart
Response.Write "<br>" & strEnd
Response.Write "<br>"
i = strStart
For i = StrStart to StrEnd
Response.Write ""& i &"" & "; "
If i > StrEnd then Exit for
Next
%>

This is outputing 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12;

Which is then easy to insert into db and then grab back. Notice that I have added a small piece for better diferentiate records. I'm afraid I have to leave you with this as here it is already late and my lady is already mad at me. So, you should check what's wrong with the output of datePart function. After you figure it up, just write an instert into db statement for i.

Cristian Banu
Soft 4 web
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.