Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Steve2106
Posting Yak Master
183 Posts |
Posted - 2008-08-21 : 09:05:17
|
| Hi Guys,Can someone help me with some query code.The results returned from my query give the dates with the time portion included. I need to get just the date part. How would I do that. My query is this:Select tbMatTrack.Description, tbMatOrg.FirstName + ' ' + tbMatOrg.LastName As ResponsiblePersonFullName, tbMatTrack.PlannedStartDate, tbMatTrack.ActualStartDate, tbMatTrack.PlannedCompletionDate, tbMatTrack.ActualCompletionDateFrom tbMatTrack Inner Join tbMatOrg On tbMatTrack.ResponsibleId = tbMatOrg.PersonnelId Where tbMatTrack.ActionId = 2And this is the date result:2008-05-26 00:00:00.000I want it to be 2008-05-26Thanks for your help,Steve.Steve |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-21 : 09:08:17
|
| Where do you want to show data?MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-21 : 09:37:17
|
| Either try to do this formatting at your front end application or if you really have to do it in T-SQL, use CONVERT with appropriate format style. Look into books online for various styles available. |
 |
|
|
Steve2106
Posting Yak Master
183 Posts |
Posted - 2008-08-21 : 09:54:12
|
| Hi There,I am using the query to pull out a record from the database into a dataset.I am then looping through the fields and building a string to send an email.I would prefer to do it in the query, if not I am using Asp.Net (VB) how would I do it once I have the dataset in VB?Thanks for your help.Best Regards,Steve.Steve |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-21 : 10:08:17
|
| Try using Format() function. |
 |
|
|
sergio211956
Starting Member
1 Post |
Posted - 2008-08-21 : 10:12:49
|
| or try:ToShortDateString() |
 |
|
|
ma.voice
Starting Member
12 Posts |
Posted - 2008-08-22 : 11:46:07
|
| hi,For TSQL fix ... try these1. select convert(varchar(14),getdate(),111)2.select convert(varchar(4),datepart(yyyy,getdate()))+'-'+convert(varchar(2),datepart(mm,getdate()))+'-'+convert(varchar(2),datepart(dd,getdate()))CheersSilent VoiceBill Gates, MVP |
 |
|
|
|
|
|
|
|