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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 short date?

Author  Topic 

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-13 : 00:38:27
Hi all. Is it possible to convert the date to shortdate?

select e.hireddate from hremployees e

it returns 2/07/2007 12:00:00 AM

How can i neglect the time?

Thanks
-Ron-

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-13 : 00:42:21
the time will always be there. However you can set it to 00:00:00 by using


select dateadd(day, datediff(day, 0, e.hireddate), 0)
from hremployees e


You can also use convert() to format the date into the required format. But it is best that you do any formatting that you required in your front end application / report


KH

Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-13 : 01:07:37
so it means time cannot be neglected / hidden?

yes, if i tried to convert the format in my report, it will affect some fields that have null dates. null will be changed to date.

thanks
-Ron-
Go to Top of Page

mk_garg20
Constraint Violating Yak Guru

343 Posts

Posted - 2007-03-13 : 01:19:15
check this out

select convert(varchar,e.hireddate,103) from hremployees e

mk_garg
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-13 : 01:28:34
quote:
null will be changed to date.

what do you mean by this ?


KH

Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-13 : 01:28:44
thanks mk_garg... ur d'best!

-Ron-
Go to Top of Page
   

- Advertisement -