By Richard Rost 12 months ago
Get Specified Part of Date. Year, Quarter, Week, etc.
In this video I will show you how to use the DatePart function to isolate specific parts of a date/time value such as the day of the year, week of the year, month, quarter, and so on. DatePart offers some options that other functions don't have.
Damon from Waterville, Ohio (a Platinum Member) asks: I have a query that shows sales for the year, but right now I have to type in the start date (say 1/1/2021) and the end date (12/31/2021) and it's a bit of a pain EVERY time I run the query. Is there any way I can simplify that to just type in the year only?
Members will learn about the FirstDayOfWeek and FirstWeekOfYear options, how to determine if a date falls within the same calendar week as the current date, and how to determine if a date falls in the same quarter of the current year.
I completely forgot to mention this in the video: the whole reason why it's handy to use the mathematical approach I showed to calculate the current quarter is because it makes it much easier to find records in the next quarter, or the previous quarter, or even use this for months. That way if you want the next quarter, and you're in the 4th quarter, you don't have to add 1 to the year and make the quarter value 1. Just use the little math trick I showed you and add 1 to that value. See how easy? I cover this in a lot more detail in the DateTime Seminar.
Silver Members and up get access to view Extended Cut videos, when available. Gold Members can download the database template from class plus get access to the Code Vault. If you signed up on YouTube you have to register on my YouTube Find User page so I can set up your account here on my web site. If you're not a member, Join Today!
microsoft access, ms access, ms access tutorial, #msaccess, #microsoftaccess, #help, #howto, #tutorial, #learn, #lesson, #training, #database, DatePart, parts of a date, year, quarter, month, day of year, week, week of year, weekday, week number, hour, minute, second, first week of year, first day of week, Date in current week of year, DatePart Function, How do you calculate quarters in Access, How do I extract month and year from date in Access
Subscribe to DatePart
Get notifications when this page is updated
Check out these other pages that may be of interest to you: