Numeric to Date calc issue

colmac
StarLounger
Posts: 65
Joined: 01 Apr 2011, 18:43

Numeric to Date calc issue

Post by colmac »

I have a date field (named BD_N) and I have a numeric field (named PB_D) containing an integer between 1 & 28 (other vales not permitted).

I need to calculate the first date after the date field using the numeric field as the value for the day of the month

So if I have

17th August 2014
&
7

I want 7th September 2014 as my answer


If I have

17th August 2014
&
26

I want 26th August 2014 as my answer

If I have

17th August 2014
&
17

I want 17th September 2014 as my answer

I'm struggling to make this work, can anyone help please. I'd prefer it not in code, as the remainder of the sheet is a simple one.

Thanks

User avatar
HansV
Administrator
Posts: 78494
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Numeric to Date calc issue

Post by HansV »

You can use the following in a query:

NewDate: DateSerial(Year([BD_N]), Month([BD_N]) + 1, [PB_D])

or the following in the Control Source of a text box on a form or report:

=DateSerial(Year([BD_N]), Month([BD_N]) + 1, [PB_D])
Best wishes,
Hans

colmac
StarLounger
Posts: 65
Joined: 01 Apr 2011, 18:43

Re: Numeric to Date calc issue

Post by colmac »

Thanks as ever.

Great help and great speed. Much appreciated.