date formatted as 24 hour in pivot table, but as 12 hour in data sheet

james_lankford

Well-known Member
Joined
Jan 11, 2009
Messages
1,222
I have a field that comes straight out of a sql server database where they are storing the date and time as a string in as yyyymmddhhmmssmm

that's year month day hour minute second millisecond

so Jan 4th of 2011, 8:26:08:02 PM looks like
2011010420260802

and, yes, it is definitely a string in sql server and comes across to excel as a string

so I break it up to a proper US date time like this

=IF(LEN(B2)<>0,DATE(MID(B2,1,4), MID(B2,5,2),MID(B2,7,2)) + TIME(MID(B2,9,2), MID(B2,11,2),MID(B2,13,2)),"")

pulling out chars and using them in the DATE and TIME functions

then I format the cell like this

[$-409]m/d/yy h:mm:ss AM/PM;@

it works fine, this is what is displayed
1/4/11 8:26:08 PM

but, when I make a pivot table this is what gets displayed
1/4/2011 20:26

I don't want that;
I want it formatted the way it is on the data sheet

I can't find a way to keep the format in the pivot table

perhaps the problem is with my formula for making a date time out of the string ?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

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