Query to keep count of current days, months, quarters YTD? (1 Viewer)

gojets1721

Registered User.
Local time
Today, 01:19
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?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:19
Joined
Oct 29, 2018
Messages
21,473
Would DateDiff() work for you?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:19
Joined
Feb 19, 2013
Messages
16,612
When does your year start since if 1st Jan month and quarter should be 0 if you want past
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 04:19
Joined
May 21, 2018
Messages
8,529
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

Top Bottom