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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 datetime to smalldatetime conversion

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2005-09-22 : 08:57:15
How to code to conver datetime data to smalldatetime? That is:
from "06/10/2005 10:23 AM" to "06/10/2005".

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-22 : 09:00:28
It depends where you want to use those converted dates
If you use them only for display purpose then

select convert(varchar,Getdate(),101)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-09-22 : 09:01:30
also check out the "dates" section of this link: (FAQ - frequently answered questions)
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210

Be One with the Optimizer
TG
Go to Top of Page

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2005-09-22 : 09:23:46
For the bigining, boss need only display. I used "convert(varchar,Getdate(),101)", it works. Now, boss want to add search feature to search time frame like "between #6/2/2000# and #6/30/2005#", can this type of data do it?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-22 : 10:23:46

Select Columns from yourTable Where DateCol >='20000206' and DateCol <='20050107'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-09-22 : 23:20:23
Tell your boss to stop being a PHB and make up his mind. Madhivan's example will work. Here are all the datetime formats, just because it's more hits for my worthless blog I never update:

http://weblogs.sqlteam.com/derrickl/archive/2005/01/08/3959.aspx

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -