Convert months and years into one end of month date

Apple08

Active Member
Joined
Nov 1, 2014
Messages
450
Hi All

I imported an Excel table into Access with two separate year and month fields, but I need to convert them into one field with end of month date. For example: 2015, Aug need to convert into Access as 31-Aug-15.

I am unable to change the Excel content before import as that is a report provided by other source.

I would appreciate it very much if someone could help to advise is there any way to do it? Many thanks.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Here are some calculations that will return the date that you want (not sure if you are using an American or European version of Access, at least one of these should work).
Code:
DateCalc: DateAdd("m",1,DateValue([MonthField] & " 1, " & [YearField]))-1
or
Code:
DateCalc2: DateAdd("m",1,DateValue("1-" & [MonthField] & " -" & [YearField]))-1
Being a date field, you can then format it any way you like, i.e. "dd-mmm-yy"
 
Upvote 0
Excellent Joe! It works perfectly! Many thanks.

However some of my year data are blank like below:

2013
(blank)
(blank)
2014
(blank)
(blank)
(blank)
2015
(blank)
(blank)

Is there anyway that the blank year can automatically copy from the year field above? Many thanks.
 
Upvote 0
Is there anyway that the blank year can automatically copy from the year field above?
I guess that depends on how you define "the year field above".
Remember, Access is not like Excel. The order of records in a table really has no meaning.
Someone one described it well, when they said to think of an Access table as "a bag of marbles", where all the records in mixed in there, in no real particular order.

Now, there are some complex ways to do that if you order your fields in a query, but I am not sure it will be worth the effort for you.
See: https://support.microsoft.com/en-us/kb/210504
and Get Value from Previous Record for this record - Microsoft Access / VBA

You may be better off going another route, like fixing your data.
 
Upvote 0
Thanks Joe. Yes it is more complicated than I expected. I will have a go and see if it is worth to carry on.

Many thanks for your help indeed!
 
Upvote 0

Forum statistics

Threads
1,221,848
Messages
6,162,404
Members
451,762
Latest member
Brainsanquine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top