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
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 youArtSioux 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) |
Tidak ada komentar:
Posting Komentar