Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: asp and dates

  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,466
    Thanks
    15
    Thanked 0 Times in 0 Posts

    asp and dates

    can someone help me?
    I need to create a function that I will pass in a date and it will retunr the 2 dates that date is in with the first date being friday 1:00 to the last datetime being thursday 12:59

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your question makes no sense to me.

    You can use DateAdd and WeekDay to get specifc dates from a passed date.
    http://www.w3schools.com/vbscript/vb..._functions.asp

  • #3
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Example
    Code:
    <%
    Function getDate(theDate)
    	Do
    		numDays=numDays+1
    		newDate = DateAdd("d",numDays,theDate)
    	Loop Until WeekDay(newDate) = 6
    	
    	If numDays=1 Then
    		numDays = "tomorrow"
    	Else
    		numDays = "in " & numDays & " days"
    	End If
    	
    	getDate = "The next Friday is " & numDays & " on " & newDate
    End Function
    
    myDate1 = "11/1/2007"
    myDate2 = "12/1/2007"
    myDate3 = "18/1/2007"
    
    Response.Write "Date: " & myDate1 & ". " & getDate(myDate1) & "<br>"
    Response.Write "Date: " & myDate2 & ". " & getDate(myDate2) & "<br>"
    Response.Write "Date: " & myDate3 & ". " & getDate(myDate3) & "<br>"
    Response.Write "Date: " & Date & ". " & getDate(Date) & "<br>"
    %>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •