Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2011

    Unanswered: Find the first and last date of that month of any day

    One may use the following script to find the first last day of that month of any day. This was very much essential for my database as it deals with payroll.

    (For understanding my database has form attendance rep)

    [$v22-month] = datePart([for the month],|Month|) (for Attendance rep)

    2 [$v42] = datePart([for the month],|Day|) (for Attendance rep)

    3 [$v22-year] = datePart([for the month],|Year|) (for Attendance rep)

    4 [$v23-firstday] = dateSerial([$v22-year],[$v22-month],1) (for Attendance rep)

    5 [$v23-lastday] = dateSerial([$v22-year],[$v22-month],31) (for Attendance rep)

    6 [$v24-months] = datePart([$v23-lastday],|Month|) (for Attendance rep)

    7 If Attendance rep And ([$v24-months] > "[$v22-month]") then

    8 [$v23-lastday] = dateSerial([$v22-year],[$v22-month],30) (for Attendance rep)

    9 [$v24-months] = datePart([$v23-lastday],|Month|) (for Attendance rep)

    10 If Attendance rep And ([$v24-months] > "[$v22-month]") then

    11 [$v23-lastday] = dateSerial([$v22-year],[$v22-month],29) (for Attendance rep)

    12 [$v24-months] = datePart([$v23-lastday],|Month|) (for Attendance rep)

    13 If Attendance rep And ([$v24-months] > "[$v22-month]") then

    14 [$v23-lastday] = dateSerial([$v22-year],[$v22-month],28) (for Attendance rep)

    15 End If

    16 End If

    17 End If

    18 Attendance rep: [Last date of the month] = "[$v23-lastday]"

    19 Attendance rep: [Start date of the month] = "[$v23-firstday]"

    20 Attendance rep: [Number of days in the month] = dateDiff([Last date of the month],[Start date of the month],|Day|)+1

  2. #2
    Join Date
    Jul 2012
    Result is the same as yours, a different method. Is not it?
    Attached Files Attached Files

  3. #3
    Join Date
    Jul 2011
    Beautifully done!!
    Your script is the shortest one.
    I welcome such tips for other area of the BDB.

  4. #4
    Join Date
    Jul 2012
    Provided Answers: 2
    Thats very handy.
    Thanks asokram, Thanks MAcHeuS


Posting Permissions

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