Results 1 to 10 of 10

Thread: Getting Current Date in VBScript

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Talking

    How do I correctly check the current date against a preset date in the future and based on that call this function EarlyPrice or the other function RegPrice?

    Here is what I have:

    Dim MyDate
    Mydate = Date ' will return system date
    If MyDate <= ' the rest is a clue to me!

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    <!--blur--!>

    hummm not sure what you are asking

    you can use dateDiff("d",date1,date2)

    d :day
    m:month
    y:year

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    If MyDate <= "12/01/2000"

    or whatever date you choose.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Talking What can I do to check against March 31, 2001?

    Whenever I use this code for setting the current system date less than or equal to the date below it doesn't recognize this format.

    What can I do to check against March 31, 2001?

    MyDate = Date

    MyDate <= "03/31/2001"

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Talking

    Whenever I use this code for setting the current system date less than or equal to the date below it doesn't recognize this format.

    What can I do to check against March 31, 2001?

    MyDate = Date

    MyDate <= "03/31/2001"

  6. #6
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Cander's suggestion should work just fine. Just make sure you Dim MyDate as Date.
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
        Dim myDate As Date
        myDate = Now()   ' or myDate = Date()
        
        If myDate <= "03/31/2001" Then
            MsgBox "Less than target date"
        End If
    End Sub

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Unhappy

    thanks, the now() works but what is wrong with my code here?

    I am trying to call either one function or the other function : It doesn't work

    Dim MyDate as Date
    MyDate = Now()

    Code:
    			If MyDate <= "3/31/2001" Then 
    				EarlyPrice()
    			Else 
    				RegPrice()

  8. #8
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Using your code, I put msgboxes in place of your function calls. The If...Then appears to be working fine.

    Are your functions declared correctly ?
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    Dim MyDate As Date
    MyDate = Now()
    
        If MyDate <= "3/31/2001" Then
            MsgBox "MyDate is less than or equal to 3/31/2001"
            'EarlyPrice()
        Else
            MsgBox "MyDate is greater than 3/31/2001"
            'RegPrice()
        End If
    End Sub

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Talking

    I forgot to tell you I am writing in Vb Script.

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    Here is the function. Is it correct?

    Code:
    <%
    
    Dim intEarlyBird
    
    Function EarlyPrice()
    	Dim strRegArray(10)
    	Dim intLoop
    		Select Case lstReg1Type 'registration type from the first grouping
    			Case "Individual"
    				strRegArray(1) = 105 
    			Case "Spouse"
    				strRegArray(1) = 95 
    			Case "ActivePulpitPastor"
    				strRegArray(1) = 75 
    			Case "SpecialStudentRate"
    				strRegArray(1) = 75 
    			Case Else 
    				Response.Redirect "ErrorType.asp"
    							
    		End Select
    		
    		Select Case lstReg2Type 'registration type from the second grouping
    			Case "Individual"
    				strRegArray(2) = 105  
    			Case "Spouse"
    				strRegArray(2) = 95 
    			Case "ActivePulpitPastor"
    				strRegArray(2) = 75 
    			Case SpecialStudentRate
    				strRegArray(2) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    		
    		Select Case lstReg3Type 'registration type from the third grouping
    			Case Individual
    				strRegArray(3) = 105 
    			Case Spouse
    				strRegArray(3) = 95 
    			Case ActivePulpitPastor
    				strRegArray(3) = 75 
    			Case SpecialStudentRate
    				strRegArray(3) = 75 
    			Case Else
     				Response.Redirect "ErrorType.asp"
    
    		End Select
    		
    		Select Case lstReg4Type 'registration type from the fourth grouping
    			Case Individual
    				strRegArray(4) = 105 
    			Case Spouse
    				strRegArray(4) = 95
    			Case ActivePulpitPastor
    				strRegArray(4) = 75 
    			Case SpecialStudentRate
    				strRegArray(4) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    		
    		Select Case lstReg5Type 'registration type from the fifth grouping
    			Case Individual
    				strRegArray(5) = 105 
    			Case Spouse
    				strRegArray(5) = 95
    			Case ActivePulpitPastor
    				strRegArray(5) = 75 
    			Case SpecialStudentRate
    				strRegArray(5) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    		Select Case lstReg6Type 'registration type from the sixth grouping
    			Case Individual
    				strRegArray(6) = 105 
    			Case Spouse
    				strRegArray(6) = 95
    			Case ActivePulpitPastor
    				strRegArray(6) = 75 
    			Case SpecialStudentRate
    				strRegArray(6) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    		Select Case lstReg7Type 'registration type from the seventh grouping
    			Case Individual
    				strRegArray(7) = 105 
    			Case Spouse
    				strRegArray(7) = 95
    			Case ActivePulpitPastor
    				strRegArray(7) = 75 
    			Case SpecialStudentRate
    				strRegArray(7) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    		Select Case lstReg8Type 'registration type from the eigth grouping
    			Case Individual
    				strRegArray(8) = 105 
    			Case Spouse
    				strRegArray(8) = 95
    			Case ActivePulpitPastor
    				strRegArray(8) = 75 
    			Case SpecialStudentRate
    				strRegArray(8) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    		Select Case lstReg9Type 'registration type from the ninth grouping
    			Case Individual
    				strRegArray(9) = 105 
    			Case Spouse
    				strRegArray(9) = 95
    			Case ActivePulpitPastor
    				strRegArray(9) = 75 
    			Case SpecialStudentRate
    				strRegArray(9) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    		Select Case lstReg10Type 'registration type from the tenth grouping
    			Case Individual
    				strRegArray(10) = 105 
    			Case Spouse
    				strRegArray(10) = 95
    			Case ActivePulpitPastor
    				strRegArray(10) = 75 
    			Case SpecialStudentRate
    				strRegArray(10) = 75
    			Case Else
    				Response.Redirect "ErrorType.asp"
    
    		End Select
    
    '-- Sum up the total selections
    		
    		For intLoop = 1 to 10
    		
    		intEarlyBird = intEarlyBird + Cint(strRegArray(intLoop))
    		
    		Next
    		
    		
    		
    		
    End Function
    		
    				
    
    
    				
    
    %>

Posting Permissions

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



Click Here to Expand Forum to Full Width