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.

 
Go Back  dBforums > PC based Database Applications > Brilliant Database > Find the first and last date of that month of any day

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Jul 2011
Posts: 130
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
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Jul 2012
Posts: 83
Result is the same as yours, a different method. Is not it?
Attached Files
File Type: zip MyDB.zip (33.1 KB, 20 views)
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Jul 2011
Posts: 130
Beautifully done!!
Your script is the shortest one.
Thanks.
I welcome such tips for other area of the BDB.
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Jul 2012
Location: Ireland
Posts: 562
Thats very handy.
Thanks asokram, Thanks MAcHeuS

Regards
James
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On