Jumat, 05 April 2019

Re: [MS_AccessPros] Date calculations

 

hi Art,

Month and year are easy since the first day is always 1 and to get the end date, use 0 for the next month. If a month is more than 12, then the DateSerial function knows what to do :)

Syntax: DateSerial( Year, Month, Day)

Beginning of Month
BOM: DateSerial( year(MyDate), month(myDate), 1)

End of Month
EOM: DateSerial( year(MyDate), month(myDate)+1, 0)

Beginning of Year
BOM: DateSerial( year(MyDate), 1, 1)

End of Year
EOM: DateSerial( year(MyDate), 13, 0)

Week is a little tougher. I have logic to do it (in my popup calendar) but right now I don't have time to dig it out (or figure it out -- the above is air code, hopefully it is right!). Maybe Duane will jump in -- he probably has it too -- or someone else..

have an awesome day,
crystal

free code you can use in your projects
https://msaccessgurus.com/code.htm


On 4/5/2019 3:51 PM, dbalorenzini@yahoo.com [MS_Access_Professionals] wrote:
I need help with calculating start and end dates for week, month and year. So far I have the following:


month:
?????? Me!txtdatefrom = CDate("01/" & Month(Date) & "/" & Year(Date))
?????? Me!txtDateTo = DateAdd("d", -1, DateAdd("m", 1, Me!txtdatefrom))

I know the txtdatefrom is right. It takes me to January but I need the first date of any month.

weekday

?? Me!txtdatefrom = DateAdd("d", (today * -1) + 2, Date)
?????? Me!txtDateTo = DateAdd("d", 6 - today, Date)

Year:


?????? Me!txtdatefrom = CDate("01/01/" & Year(Date))
?????? Me!txtDateTo = DateAdd("d", -1, DateAdd("yyyy", 1, Me!txtdatefrom))

Any advice would be great!\

Thank you
Art
Sioux Falls, SD


__._,_.___

Posted by: crystal 8 <strive4peace2008@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


SPONSORED LINKS
.

__,_._,___

Tidak ada komentar:

Posting Komentar