|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Date Queryi am trying to run the query tht only brings the date. In our database we
have a date record like that (1999-05-18 00:00:00.000) Is there any way I run query and only bring date(1999-05-18) not time (00:00:00.000)? thanks Farrukh Sure, but you can't separate date and time. The only way to do what you're
asking is to convert it to a string. Why can't the application / presentation tier / reporting tool format the date appropriately? SELECT column_name = CONVERT(CHAR(10), column_name, 120) FROM table; Show quote "FARRUKH" <farrscorpi***@hotmail.com> wrote in message news:7EC69F1E-B9BB-405A-8A79-388A2E0B93C6@microsoft.com... >i am trying to run the query tht only brings the date. In our database we > have a date record like that (1999-05-18 00:00:00.000) > > Is there any way I run query and only bring date(1999-05-18) not time > (00:00:00.000)? > > thanks > > Farrukh > > I dont want to see the time cuz its all zero. I just joined this company so i
dont know Show quote "Aaron Bertrand [SQL Server MVP]" wrote: > Sure, but you can't separate date and time. The only way to do what you're > asking is to convert it to a string. > > Why can't the application / presentation tier / reporting tool format the > date appropriately? > > SELECT column_name = CONVERT(CHAR(10), column_name, 120) FROM table; > > > > "FARRUKH" <farrscorpi***@hotmail.com> wrote in message > news:7EC69F1E-B9BB-405A-8A79-388A2E0B93C6@microsoft.com... > >i am trying to run the query tht only brings the date. In our database we > > have a date record like that (1999-05-18 00:00:00.000) > > > > Is there any way I run query and only bring date(1999-05-18) not time > > (00:00:00.000)? > > > > thanks > > > > Farrukh > > > > > > > This should bring you up to speed on how the datetime datatype work in SQL Server:
http://www.karaszi.com/SQLServer/info_datetime.asp -- Show quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ "FARRUKH" <farrscorpi***@hotmail.com> wrote in message news:F316BEF9-999D-4807-A69E-29EFE94B22EE@microsoft.com... >I dont want to see the time cuz its all zero. I just joined this company so i > dont know > > "Aaron Bertrand [SQL Server MVP]" wrote: > >> Sure, but you can't separate date and time. The only way to do what you're >> asking is to convert it to a string. >> >> Why can't the application / presentation tier / reporting tool format the >> date appropriately? >> >> SELECT column_name = CONVERT(CHAR(10), column_name, 120) FROM table; >> >> >> >> "FARRUKH" <farrscorpi***@hotmail.com> wrote in message >> news:7EC69F1E-B9BB-405A-8A79-388A2E0B93C6@microsoft.com... >> >i am trying to run the query tht only brings the date. In our database we >> > have a date record like that (1999-05-18 00:00:00.000) >> > >> > Is there any way I run query and only bring date(1999-05-18) not time >> > (00:00:00.000)? >> > >> > thanks >> > >> > Farrukh >> > >> > >> >> >> Formatting data for presentation is best done in the client
application -it's MUCH easier in the client languages. However, if you have to do so in SQL, then you could do something like the following: SELECT convert( varchar(10), getdate(), 120 ) -- Show quoteArnie Rowland, Ph.D. Westwood Consulting, Inc Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous "FARRUKH" <farrscorpi***@hotmail.com> wrote in message news:7EC69F1E-B9BB-405A-8A79-388A2E0B93C6@microsoft.com... >i am trying to run the query tht only brings the date. In our database we > have a date record like that (1999-05-18 00:00:00.000) > > Is there any way I run query and only bring date(1999-05-18) not time > (00:00:00.000)? > > thanks > > Farrukh > > in addition to what others have said, I believe there is an ODBC setting
that will control the date format for you, but I am not sure off hand. Show quote "FARRUKH" <farrscorpi***@hotmail.com> wrote in message news:7EC69F1E-B9BB-405A-8A79-388A2E0B93C6@microsoft.com... > i am trying to run the query tht only brings the date. In our database we > have a date record like that (1999-05-18 00:00:00.000) > > Is there any way I run query and only bring date(1999-05-18) not time > (00:00:00.000)? > > thanks > > Farrukh > >
Other interesting topics
|
|||||||||||||||||||||||