Skip to main content
Known Participant
Jul 9, 2024 11:48 AM UTC
Question

Compare datetime field with date(Fetch Duplicate request)

I have a datetime field in DB. When user selects datetime from interface, i want to make sure that date doesn't already exist in DB. Basically, i am trying to fetch duplicate requests for a day. 

I cannot use "=" operator since field is of datetime type not date and if i use other operators such as startswith, in, includes , it gives me error i.e. Cannot apply operator [INCLUDES] to field [dateTime] when comparing to value [TypedValue[it=9,v=2024-07-05 05:00:00.0]].

    2 replies

    Brainy
    Jul 9, 2024 12:17 PM UTC
    Option - 1: If you are using Record Type, you can create a custom field using your existing field. Then, you can make a query on this new custom field.
    Option - 2: Use Between operator
    venkatrea696188
    Inspiring
    Jul 9, 2024 4:21 PM UTC
    i want to make sure that date doesn't already exist in DB. Basically, i am trying to fetch duplicate requests for a day

    And how you are comparing?? Querying data after user enters value on interface or Comparing with already fetched data?? . If you are going with first one the both approaches suggested by Yogi would work.

    If it's second one just wrapping todate() around variable will do the work.