Setfilter for DateTime data type

garychickgarychick Member Posts: 34
edited 2005-06-29 in Navision Attain
Hi ALL,

What I want to do is the same as Starting Date Filter in Form 7002. But the data type of my record is DateTime and the input filter is Date (like the Starting Date Filter textbox in Form 7002).

I used SETFILTER("Created DateTime", DateFilter), but nothing will be returned.

Can anyone give me some opinions?

Comments

  • Timo_LässerTimo_Lässer Member Posts: 481
    1. You can't filter a datetime field with a date field.
      You first have to create a datetime value out of your date value.
    2. If you want to get the "date filter" field value you must use GETFILTER
    If "DateFilter" is a variable, use this
    SETFILTER("Created DateTime",CREATEDATETIME(DateFilter),0T);
    
    If you mean the field "Date Filter", then use this
    SETFILTER("Created DateTime",CREATEDATETIME(GETFILTER("Date Filter")),0T);
    
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Timo_LässerTimo_Lässer Member Posts: 481
    http://www.mibuso.com/forum/viewtopic.php?p=24289
    garychick wrote:
    Thank you for your reply.

    But I only want to filter the "date" part of DateTime. I need to ignore the Time part. How to do so?

    By the way, can I create a flow field (as in Date datatype) in the same table of the DataTime field which extracts the date of the DateTime field?
    If you read my Code carefully, you see
    SETFILTER("Created DateTime",CREATEDATETIME(DateFilter,0T));
    This creates a datetime from your date and the unspecified time 0T.

    To extract the date part from a datetime use
    Date := DT2DATE(Datetime);
    
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
Sign In or Register to comment.