Format issue code without office 365

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,302
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

I have the code below that works fine in office 365 however some of my colleagues aint on office 365 and throws a format error issue on the line below

How can i get around it to work on both versions?

DoCmd.RunSQL "UPDATE WFM_AllResults SET Date_ = FORMAT(Date_,'dd/mm/yyyy'),[Datetime] = CDate(CStr([Date_]) & ' ' & Period & ':00')"
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hiya - its the way the date field was saved originally
 
Upvote 0
That's a weird formula. What is it supposed to do? Have you tested it? Can you give a sample input and output?
 
Upvote 0
Hiya

i have a date and period column

what im trying to do is change/set the date column to dd/mm/yyyy and change the datetime column to combine the date and period column but treating it as datetime

ie

02/07/2020, 01:00
To
Date_, Period, DateTime
07/02/2020, 01:00, 07/02/2020 01:00
 
Upvote 0
I think you need to put them together first and then convert to a date...

Not tested: cDate([Date_] & ' ' & [Period])
 
Upvote 0
02/07/2020, 01:00

is this data in one field or two fields? I'm not sure why you have a comma in there...

Also what is the data type of your input fields?
 
Upvote 0
sorry Xenou - my bad, spotted where the issue was with the syntax - thank you all
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,384
Members
448,956
Latest member
JPav

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