Results 1 to 5 of 5

Thread: [RESOLVED] question about Date and DateAdd.

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2008
    Posts
    255

    Resolved [RESOLVED] question about Date and DateAdd.

    Dear all,

    I have the following Pseudo code and my questions are include in the remark: 'how to write this? and RED in color

    Sorry for not be able to ask my questions clearly and thank you for your help in advance.

    Code:
    public function fn_matched_date(p_hit_weekday as string, _ 
                                    p_control_Date as date, p_Input_Date as date) as date
    
    Dim isExist as boolean
    
    'p_Hit_Weekday=2,6 'Wednesday and Friday
    'p_control_Date=#01-Jul-2009#
    'p_Input_Date=#21-Apr-2009#
    
    while p_input_date <= p_control_Date
      if p_input_date is in (p_hit_weekday) then 'How to write this?
         'Check if p_input_date is Wed or friday which are the values in the variable p_Hit_weekday
    
         isExist = fn_Date_Exist(p_input_date)
         'Check if this date exists in a database table by an existing function: fn_date_exists     
      else
         p_input_date=add to the next nearest hit weekday 'How to write this?
       '1st e.g. if p_input_date is thursday, it need to add one date so that it will become friday
       '2nd e.g. if p_input_date is monday, it need to add two dates so that it will become Wednesday
       '3rd e.g. if the variable p_hit_weeday is having the values: 3,4 , and if p_input_date is monday, it need to add three dates so that it will become Thursday
    
         isExist = fn_Date_Exist(p_input_date)
      end if
    
       if isExist then
          fn_matched_date = p_input_date
          exist the while loop
       else
          p_input_date=add to the next nearest hit weekday
          'to continue the looping until it find the matched date
       end if
    
    wend
    
      if not isExist then
         fn_matched_date = #31/12/1899#         
      end if
      ' return an invalid date in case it cannot find the matched date
    
    End function
    Last edited by lok1234; Apr 21st, 2009 at 09:03 PM.

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