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 ?
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 ?