Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

syedhasy's avatar

count

when user give only year i have to list the total count of particular year if user gave month and year like 12/2022 i have to list the total count of particular month of the year if user gave day month and year like 12/31/2022 i have to list exact count on the particular year if suppose user gave from date value and to date value like from:01/01/2022,to:12/31/2022 i will list the total count using between if suppose user gave from date value and to date value like from:01/2022,to:12/2022 i will list the total count of each month of each year if suppose user gave from date value and to date value like from:2022,to:2022 i will list the total count of each year any suggest for this?

0 likes
6 replies
syedhasy's avatar

hey guys i have figured a issue like when i use whereBetween('created_at',[2022-09-01,2022-09-31]) i getting the dates of 30th but when i use 30 instead of 31 i am not getting 30th day count can anyone help me for this

Tray2's avatar
Tray2
Best Answer
Level 73

@syedhasy Try converting timestamp to date

->whereBetween(DB:raw('DATE(created_at)'), [$startDate. $endDate])
syedhasy's avatar

@Tray2 what exactly it do because i have queried like between '2022-09-01 00:00:00' and '2022-09-30 23:59:59' it works

Tray2's avatar

@syedhasy It removes the need for specifying a time.

2022-05-01 17:00:10 => 2022-05-01

1 like

Please or to participate in this conversation.