Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

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

$
0
0
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

Viewing all articles
Browse latest Browse all 13329

Trending Articles