Creating a GI or report parameter to filter a datetime field by date AND time

  • 18 November 2020
  • 20 replies
  • 3739 views

Userlevel 7
Badge +7

Recently we had the requirement to create a Generic Inquiry and Report with parameters to filter on a date range using both date AND time to account for multiple labor shifts. 

I could not identify a schema field that included a time component, so I created two additional string parameters for the time components.  I then parsed the time parameter and added the corresponding number of minutes to adjust the start and end dates in the GI/Report condition.  I also had to make an adjustment for UTC, which works differently between the GI and the Report.  

GI search screen:

Condition on the GI:

It seems a bit hacky, but it does do the trick.  Has anyone else encountered this requirement and possibly found an easier method to provide the functionality?

 


20 replies

I am struggling with the created on date field myself, can you send me your whole condition as the right side is cut out, i believe it is exactly what I need to do!

Userlevel 7
Badge +7

@Mike Baio 

There may be a better way, but this approach worked for our situation:

=DateAdd([BegDate] , 'n' , IIf([BegTime]=null, 0, IIf(len([BegTime])=5, (CInt(left([BegTime], 2))+5)*60 + CInt(Right([BegTime], 2)), IIf(len([BegTime])=4, (CInt(left([BegTime], 1))+5)*60 + CInt(Right([BegTime], 2)), 0))))

Thank you, here is what I’m really trying to do, basically generate a report that shows everything that was created in a certain area for a day in time.  So for example, in Payables, I would like to see a report off the register file that shows all the transactions that have a createDateTime date of a particular parameter.  I think it has to do with this date time thing why its not working.  

Userlevel 7
Badge +7

@Mike Baio

I created the extra “time” parameters because the schema for a date/time field does not allow you to specify a time.  With four parameters (start date, start time, end date, end time) the user can specify both a start and an end time.  The formula converts the time into seconds and adds that number of seconds to the date parameters to create the formula for the condition.  

This is how I configured the parameters:

 

i believe i got it to work, thank you, your formula let me see this from another perspective!

Userlevel 3
Badge

Hi @lauraj46 , I’m trying to use a condition off of the PMProject.CreatedDateTime field but I don’t need the time as part of the condition, just the date. I just need to filter the list of projects for ones created on or after 1/1/2021. I’ve tried the below a few different ways but I continue to get an “ Incorrect syntax near '>' ” error. Do you have any suggestions?
 

 

Userlevel 7
Badge +7

 

 

Hi @cshaheen26 , 

Your formula on the right hand side of the condition should not include the > sign, instead specify the ‘Greater Than or Equal To’ option only in the condition.

You can also use the date relative parameters that Acumatica provides such as @YearStart.  This will allow your GI to continue working next year without having to go back and change the date.  

In order to implement this, I would typically create a parameter on the Parameters tab, and then reference it in the condition, see screenshots below:

 

Hope this helps!

Laura

Userlevel 3
Badge

It did! Thank you so much, @lauraj46 

Hi @lauraj46 

How can I set the specific No. of Days in the condition of Generic Inquiry?

Thank you

Userlevel 7
Badge +7

Hi @jamesaldo ,

You can use the DateDiff and  DateAdd functions in the condition to calculate or adjust the difference in days.  Can you explain a little bit more about what you are trying to accomplish? 

Laura

Hi @lauraj46 ,

I’m struggling to set the specific no. of days in the condition, I always get the incorrect results.

Sample: Days are only 13 days starting from the date created.
 

 

Userlevel 7
Badge +7

@jamesaldo 

If I’m understanding correctly, you would like to calculate the number of days since the record was created?

In the Results Grid you can use a formula such as this to calculate the difference in days:

 

This condition will return Cases that were created in the last 365 days:

 

Another technique I sometimes find useful is to create a parameter for use in the condition.  You can allow users to change the default, or make it not visible if you don’t want that option. 

In the Default Value you can use Date-Relative values such as @Today, @WeekStart, @MonthStart, @QuarterStart, @YearStart.  There is also the ability to add or subtract a number of days such as 365 in the example below. 

Once you have defined the parameter, you can use that in your condition like so:

I hope that helps!

Laura

Hi Ms. @lauraj46 ,

Thank you so much for the help, :grin::blush::blush:

My Generic Inquiry is working now and today I can show the records with any required days. 

I used this formula that you’ve provided.
 

 

Userlevel 5
Badge +1

FYI this thread was very helpful for me today !!!

Userlevel 1
Badge

Hi! I’m trying to calculate a month start and month end date field in the results grid a GI. I have the =DateAdd(Today(),’d’,-1) formula working but, I’d like to use a formula that works like the @MonthStart and @MonthEnd function does so it handles months that are 30 days and 31 days long. Does anyone happen to know of one?

Userlevel 7
Badge +7

Hi @Bree612 ,

To find the last day of the previous month, you can use the DatePart function to find the day of the month and then subtract that number of days:

=DateAdd(Today(), 'd', -1*Day(Today()))

To find the last of the current month you can use this formula which calculates the first day of the current month, adds one month to get the first day of the next month, then subtracts 1 day to get the last day of the current month.

=DateAdd(DateAdd(DateAdd(Today(), 'd', -1*Day(Today())+1), 'm', 1), 'd', -1)

Hope this helps!

Laura

Userlevel 1
Badge

amazing! thank you @lauraj46. I was able to get what I needed

Userlevel 1
Badge

Hi @lauraj46 ,

is there a way the time component can be prevented from being displayed in the GI results for these formulas?

=DateAdd(Today(), 'd', -1*Day(Today()))

=DateAdd(DateAdd(DateAdd(Today(), 'd', -1*Day(Today())+1), 'm', 1), 'd', -1)

Userlevel 7
Badge +7

Hi @Bree612 ,

Yes, that can be done be specifying a schema field that is formatted as a date only.  

Hope this helps!

Laura

Userlevel 1
Badge

Indeed it does Laura! ~ Bree

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved