- 
  Notifications
 
You must be signed in to change notification settings  - Fork 1.4k
 
Filter documents with only date and only time (whereDate, whereTime) #2485
 
 Unanswered
 
 
 
 
 duonghainbs
 
 
 
 asked this question in
 Q&A
 
 -
I have a list of documents in which there is a date field as follows
ISODate("2020-05-28T06:34:23.000Z")
how to filter out data with only date and time distinct condition
$db
->whereDate('dateShot', '>=', Carbon::parse('2020-05-28'))
->whereDate('dateShot', '<=', Carbon::parse('2020-05-29'))
->whereTime('dateShot', '>=', Carbon::parse('06:00'))
->whereTime('dateShot', '<=', Carbon::parse('08:00'))
or
$db
->whereDate('dateShot', '>=', '2020-05-28')
->whereDate('dateShot', '<=', '2020-05-29')
->whereTime('dateShot', '>=', '06:00')
->whereTime('dateShot', '<=', '08:00')
or
$db
->where('dateShot', '>=', '2020-05-28 00:00:00')
->where('dateShot', '<=', '2020-05-29 23:59:59')
->whereTime('dateShot', '>=', '06:00')
->whereTime('dateShot', '<=', '08:00')
All examples above return null, with the above examples used on mysql is ok.
Thank !
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
 
 Sign up for free
 to join this conversation on GitHub.
 Already have an account?
 Sign in to comment