BOFocus – Crystal Reports Tips – Tricks – Tutorials

Crystal Reports - Formulas

Adding a month/day or months/days to a date

Add months, days, years to a date field.  With the dateadd function, you can use any of the interval types listed below to add/subtact a value to a date feild.

yyyy Year
q Quarter
m Month
y Day of Year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second

Subtact a one day: DateAdd(“d”, -1, {date_field})
Add two months: DateAdd (“m”, 2, {date_field})

Note: If you are attempting to use the DateAdd function with a datetime field, you’ll need to convert the datetime field to a date field: Example:   Date(DateAdd (“m”, 1, {date_field})

Tagged , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

GET SOCIAL

QUICK TIP

The options available in the Format Editor are dependent on the type of field that is being formatted.

ADVERTISMENT