Results 1 to 2 of 2

Thread: dateadd process change

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2011
    Posts
    255

    dateadd process change

    i have this code that when u pick annually and enter 2 dates it adds the dates to database here is the code

    Code:
    If Text1(4).Text = "" And Text1(5).Text = "" Then  
    Text1(4).Text = Text1(1).Text  
    Text1(5).Text = Text1(2).Text  
        
      
    Else  
    ' User Entered Data So Use That  
    Text1(1).Text = Text1(4).Text  
    Text1(2).Text = Text1(5).Text  
      
      
         End If
    Select Case Combo1(0).Text ' Combo1(0) is the zero(0) index of the combo box control array
    Case "A"
    Call Annually(Text1(0).Text, Text1(1).Text, Text1(2).Text)




    Code:
    Public Sub Annually(SecID As String, INTSTRTDTE As String, INTENDDTE As String)  
      
    Dim dteRunningDate As Date  
    Dim VDate As Date  
    Dim i As Integer  
    Dim intInterval As Integer  
    Dim sTempCalendar As String  
    Dim dte As Date  
     Dim sSql As String  
     Dim Seq As String  
    Dim sTempCCY As String  
      
      
    sSql = "DELETE FROM SCHC WHERE SECID = '" & UCase(Text1(0).Text) & "'"  
      DBCALL "SELECT", "SCHC", sSql  
     Seq = 0  
              
            
               
              
                 
         
            'dteRunningDate = CheckDateRules(DateAdd("m", 1, dteRunningDate))  
             dte = (DateAdd("m", 12, INTSTRTDTE))  
               
               
            ' Vdate = (DateAdd("m", 12, INTSTRTDTE))  
          dteRunningDate = CheckDateRules(VDate)  
          dteRunningDate = Format(CDate(dteRunningDate), "dd mmm yyyy")  
      
     'dteRunningDate = CheckDateRules(DateAdd("m", 1, INTSTRTDTE))  
      
        Do While dteRunningDate <= INTENDDTE  
               
            sSql = "INSERT INTO SCHC VALUES('" & SecID & "','" & Seq & "','" & INTSTRTDTE & "','" & dteRunningDate & "')"  
              
            DBCALL "SELECT", "SCHC", sSql  
                If result <> 100 Then  
                    Message 43  
                    result = 1  
                End If  
    Debug.Print SecID & vbTab; Seq & vbTab; INTSTRTDTE & vbTab & dteRunningDate  
           INTSTRTDTE = dteRunningDate  
         
            'dteRunningDate = CheckDateRules(DateAdd("m", 1, dteRunningDate))  
             dte = (DateAdd("m", 12, dte))  
          dteRunningDate = CheckDateRules(dte)  
          dteRunningDate = Format(CDate(dteRunningDate), "dd mmm yyyy")  
            Seq = Seq + 1  
        
      Loop  
        If dteRunningDate <> INTENDDTE Then  
            sSql = "INSERT INTO SCHC VALUES('" & SecID & "','" & Seq & "','" & INTSTRTDTE & "','" & INTENDDTE & "')"  
                    DBCALL "SELECT", "SCHC", sSql  
                If result <> 100 Then  
                    Message 43  
                    result = 1  
                End If  
        End If  
      
       
    End Sub

    it works fine if u enter a the dates say 20 jan 2010 - 20 jan 2013

    it returns the following

    11.375FNBS49 0 20100120 20110120
    11.375FNBS49 1 20110120 20120120
    11.375FNBS49 2 20120120 20130120
    11.375FNBS49 3 20130120 20130120


    which is right

    but there could be a case where the dates in two of the text boxes are 20 jan 2010 - 20 jan 2013

    but i want to say start at the 20 march 2010 - 20 jan 2013

    so what i want to happen is the first entry is

    20 jan 2010- 20 march 2010

    and then go from the 20 march 2010 to the 20 jan 2013

    how can i change my code for this to work

  2. #2
    New Member
    Join Date
    Nov 2012
    Posts
    11

    Re: dateadd process change

    If I understand your question correctly then I reckon simply check the date. If the user enters date x and date x is within the rules then change it to y. No?

    If x = ruledate then x = y --> Then do your magic.

    Not very sure how you will determine what date needs to change as it is not stated here.

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