- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
using dateadd function to come up with daily sales but only want for the month and not prior month
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-18-2012 02:47 PM
using dateadd function to pull daily sales so some months like January, March, etc...have 31 days and Feb has 28 or 29 and the others have 30 so on my report I have formula =if dateadd("d",-30,(?Monthenddate})={ar_invoicehistor
Re: using dateadd function to come up with daily sales but only want for the month and not prior mon
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-18-2012 07:13 PM - last edited on 01-19-2012 10:26 AM
I prefer to use the DateSerial function because the month or day parameter can be increased and it will automatically resolve into the next period. This provides for simple formulas like the one below where one only needs to change the variable ClmnDay for each. The same formula works for all 31 possible days and all 12 months. Also, any day in the month works as a parameter.
Local NumberVar ClmnDay := 1;
if Month({AR_InvoiceHeader.InvoiceDate}) = Month(DateSerial(Year({?ME_Date}), Month({?ME_Date}), ClmnDay))
Then (
If {AR_InvoiceHeader.InvoiceDate} =
DateSerial(Year({?ME_Date}), Month({?ME_Date}), ClmnDay)
Then {@sales}
Else 0
)
Else 0A similar formula can be used to suppress printing in columns instead of showing zeros for days beyond actual in a given month.
Re: using dateadd function to come up with daily sales but only want for the month and not prior mon
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-19-2012 06:22 AM
Formula works great however I also used the dateadd to pull the date as title of the column but can't seem to get this new function to pull the date as a title. Can this be done?
Re: using dateadd function to come up with daily sales but only want for the month and not prior mon
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-19-2012 06:42 AM
Actually when I try and use this formula as follows to get 31 days and month end date is 4/30/12 it returns error that a day number must be between 1 and the number of days in the month
Local NumberVar ClmnDay := 31;
if Month({AR_InvoiceHistoryHeader.InvoiceDate}) = Month(DateValue(Year({?Month End Date}), Month({?Month End Date}), ClmnDay))
Then (
If {AR_InvoiceHistoryHeader.InvoiceDate} =
DateValue(Year({?Month End Date}), Month({?Month End Date}), ClmnDay)
Then {@sales}
Else 0
)
Else 0
Re: using dateadd function to come up with daily sales but only want for the month and not prior mon
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-19-2012 10:24 AM
My bad, I confused the DateValue function with the DateSerial function. I'll change the above example to use DateSerial so that you won't get that message on days with less than 31 days.
For the labels you could use:
Local NumberVar ClmnDay := 31;
if Month(DateSerial(Year({?ME_Date}), Month({?ME_Date}), ClmnDay-1)) =
Month(DateSerial(Year({?ME_Date}), Month({?ME_Date}), ClmnDay)) or ClmnDay = 1
Then ToText(DateSerial(Year({?ME_Date}), Month({?ME_Date}), ClmnDay),"MM/dd/yyyy")
Else ""
If the column value formula works for you, please mark it as the solution so others can find it.
Re: using dateadd function to come up with daily sales but only want for the month and not prior mon
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-20-2012 05:26 PM
Thanks both worked perfectly!


