Query to keep count of current days, months, quarters YTD?

gojets1721

Registered User.
Local time
Today, 15:20
Joined
Jun 11, 2019
Messages
430
I have a bit of an odd one....I was wondering if there's a way to have 1 (or 3 if needed) queries just keep a running separate count of how many days have passed YTD, how many months YTD, and how many quarters YTD.

So as of today, I would want to show 28 days in one field, 1 month in another, and 1 quarter in another.

I hope that makes sense. Any suggestions?
 
Would DateDiff() work for you?
 
When does your year start since if 1st Jan month and quarter should be 0 if you want past
 
You said "Passed" but your example shows what day, month, and qtr we are currently in not what has passed.
Code:
SELECT Datediff("d", Dateserial(Year(DATE()), 1, 1), DATE())
       + 1                 AS DayOfYear,
       Month(DATE())       AS MonthOfYear,
       Format(DATE(), "q") AS Quarter;
 
Last edited:

Users who are viewing this thread

Back
Top Bottom