If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

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

 asokram Registered User Join Date: Jul 2011 Posts: 131
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
 MacHeuS Registered User Join Date: Jul 2012 Posts: 83
Result is the same as yours, a different method. Is not it?
Attached Files
 MyDB.zip (33.1 KB, 21 views)
 asokram Registered User Join Date: Jul 2011 Posts: 131
 Beautifully done!! Your script is the shortest one. Thanks. I welcome such tips for other area of the BDB.