|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Converting DateTimeCONVERT() function like CODE 1 to transform a DATETIME field, dtMyDateTimeField, so it gets rid of the time part as shown. I do it this way so when I query from Excel, I only see 1/3/2006 for this example inside Excel. What I'm trying to do is modify my CONVERT() statement, so it keeps the date and time and will look like DESIRED RESULTS. My reason for doing this that if I just query dtMyDateTimeField without any conversion, my Excel pivot chart displays dtMyDateTimeField with military times. Even when I change the formatting to be like DESIRED RESULTS within Excel, the pivot chart displays the tme in military format. Can someone help me change CODE 1 to include the time, but keep it as date time type? CODE 1 ********************************** CONVERT(varchar(12), dtMyDateTimeField, 101), 101) AS DateRunStart = 1/3/2006 12:00:00 AM DESIRED RESULTS ************************ 1/3/2006 6:20:23 AM Seems like the simplest way to handle this would be to change the
cell's/column's time format in Excel. And the same goes for the how the chart presents label values. It's a client side formatting issue, best done in the client application. You might get assistance in one of the many Excel newsgroups at microsoft.public.excel. -- Show quoteArnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous "Scott" <sbai***@mileslumber.com> wrote in message news:e8GlJhytGHA.2392@TK2MSFTNGP05.phx.gbl... > There maybe a more efficient way to write this, but I normally use the > CONVERT() function like CODE 1 to transform a DATETIME field, > dtMyDateTimeField, so it gets rid of the time part as shown. I do it this > way so when I query from Excel, I only see 1/3/2006 for this example > inside Excel. > > What I'm trying to do is modify my CONVERT() statement, so it keeps the > date and time and will look like DESIRED RESULTS. My reason for doing this > that if I just query dtMyDateTimeField without any conversion, my Excel > pivot chart displays dtMyDateTimeField with military times. Even when I > change the formatting to be like DESIRED RESULTS within Excel, the pivot > chart displays the tme in military format. > > Can someone help me change CODE 1 to include the time, but keep it as date > time type? > > CODE 1 ********************************** > > CONVERT(varchar(12), dtMyDateTimeField, 101), 101) AS DateRunStart = > 1/3/2006 12:00:00 AM > > DESIRED RESULTS ************************ > > 1/3/2006 6:20:23 AM > I'll take it to excel forum because the pivot chart always shows military
time, even after changing the format as you suggested. thanks Show quote "Arnie Rowland" <ar***@1568.com> wrote in message news:eZdQlyytGHA.1284@TK2MSFTNGP05.phx.gbl... > Seems like the simplest way to handle this would be to change the > cell's/column's time format in Excel. > > And the same goes for the how the chart presents label values. > > It's a client side formatting issue, best done in the client application. > > You might get assistance in one of the many Excel newsgroups at > microsoft.public.excel. > > -- > Arnie Rowland, Ph.D. > Westwood Consulting, Inc > > Most good judgment comes from experience. > Most experience comes from bad judgment. > - Anonymous > > > "Scott" <sbai***@mileslumber.com> wrote in message > news:e8GlJhytGHA.2392@TK2MSFTNGP05.phx.gbl... >> There maybe a more efficient way to write this, but I normally use the >> CONVERT() function like CODE 1 to transform a DATETIME field, >> dtMyDateTimeField, so it gets rid of the time part as shown. I do it this >> way so when I query from Excel, I only see 1/3/2006 for this example >> inside Excel. >> >> What I'm trying to do is modify my CONVERT() statement, so it keeps the >> date and time and will look like DESIRED RESULTS. My reason for doing >> this that if I just query dtMyDateTimeField without any conversion, my >> Excel pivot chart displays dtMyDateTimeField with military times. Even >> when I change the formatting to be like DESIRED RESULTS within Excel, the >> pivot chart displays the tme in military format. >> >> Can someone help me change CODE 1 to include the time, but keep it as >> date time type? >> >> CODE 1 ********************************** >> >> CONVERT(varchar(12), dtMyDateTimeField, 101), 101) AS DateRunStart = >> 1/3/2006 12:00:00 AM >> >> DESIRED RESULTS ************************ >> >> 1/3/2006 6:20:23 AM >> > > |
|||||||||||||||||||||||