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)
 wantOnly Date

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-02-10 : 08:18:57
I,me&myself writes "i am using the stored procedure which inserts product info in the cart and the GetDate() to insert date and time of order.
however i want only the date to be insered and not the time.
Like in case of hardcoding..it will set the default time.even this is ok.
I just want the date and not time or the date and default time.
Is there any way to do this with ?
u.s.a.
I ,me & myself"

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-02-10 : 08:25:05
Look at the convert function in BOL

Select convert(varchar,getdate(),101)

Corey

"If the only tool you have is a hammer, the whole world looks like a nail." - Mark Twain
Go to Top of Page

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2005-02-10 : 10:12:13
Here are some more variation on this:

SELECT DATEADD(d,DATEDIFF(d,0,getdate()),0)
SELECT CONVERT(DATETIME,CONVERT(CHAR(8),GETDATE(),112))
SELECT CONVERT(CHAR(8),GETDATE(),112)

SELECT CAST(CAST(GETDATE() AS VARCHAR(12)) AS DATETIME)
SELECT CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)

SELECT CAST(SUBSTRING(CAST(GETDATE() AS BINARY(8)),1,4) + 0x00000000 AS DATETIME)
SELECT CAST(CAST(SUBSTRING(CAST(GETDATE() AS binary(8)),1,4) AS INT) AS DATETIME)



--
Frank
http://www.insidesql.de
Go to Top of Page
   

- Advertisement -