Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Date Arithmetic in ASP
Old 11-02-2005, 08:47 AM Date Arithmetic in ASP
Junior Talker

Posts: 2
Trades: 0
Hi,

I've got a date (let's call it JoinDate) being picked up from a drop down menu on a form in the format dd/mm/yyyy

On the following page of the form I need to specify another date (let's call it NewDate) based on the original that meets the following criteria:

1. If the day in JoinDate is earlier than the 7th then NewDate should be the 6th of the following month.

2. If the day in JoinDate is the 7th of the month or later then NewDate should be the 6th of the month after the following month.

So, for example, if JoinDate was 04/11/2005 NewDate would be 06/12/2005 but if it was 07/11/2005 NewDate would be 06/01/2006.

Can anyone help me with how this should be expressed in ASP code. I'm guessing I need to break down JoinDate into the day, month and year elements but then I need to find a way to treat the elements as components of a date or as integers to be able to use operators like ">" and "<=" etc.

Any help would be appreciated,

Bob
bobwhosmiles is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-02-2005, 11:52 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Day(), Month(), Year()

Code:
joinDay = day(JoinDate)
joinMonth = month(JoinDate)
joinYear = year(JoinDate)
select case joinDay
case 1,2,3,4,5,6
     newDate = dateadd("M",1,cdate("06/" & joinMonth  "/" & joinYear))
case else
     newDate = dateadd("M",2,cdate("06"/" & joinMonth  "/" & joinYear))
end select
Not tested but should add 1 month if the day is between 1 and 6 but add 2 months if it is 7 or over.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-03-2005, 05:21 AM Solved! - Date Arithmetic in ASP
Junior Talker

Posts: 2
Trades: 0
Aha - it's just like VBA. I'm new to all this but have a fair bit of experience writing this sort of thing in Excel etc using the Visual Basic editor.

Works a treat - thanks!

Bob
bobwhosmiles is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Date Arithmetic in ASP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11174 seconds with 12 queries