Wednesday, March 21, 2012

Getdate

I believe set @.today=getdate will give me the current time.
How can I get the system date without the time?GETDATE() gives you the current date & time. There are no separate date and
time datatypes in SQL Server. You can use CONVERT() to get a string that
represents the Date portion. Something like
SELECT CONVERT(VARCHAR(10),GETDATE(),101)
Check out CONVERT in BOL for more details. Also have a look here:
http://www.karaszi.com/SQLServer/info_datetime.asp Guide to Datetimes
http://www.sqlservercentral.com/col...sqldatetime.asp
Datetimes
http://www.murach.com/books/sqls/article.htm Datetime Searching
Andrew J. Kelly SQL MVP
"Arne" <Arne@.discussions.microsoft.com> wrote in message
news:CCA1E736-0033-4025-8BC8-671B0BB1C793@.microsoft.com...
>I believe set @.today=getdate will give me the current time.
> How can I get the system date without the time?|||DECLARE @.today DATETIME
SET @.today = GETDATE()
SELECT @.today
SET @.today = DATEADD(day,DATEDIFF(day,0,@.today), 0) --Strip off the time
part
SELECT @.today
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
"Arne" <Arne@.discussions.microsoft.com> wrote in message
news:CCA1E736-0033-4025-8BC8-671B0BB1C793@.microsoft.com...
>I believe set @.today=getdate will give me the current time.
> How can I get the system date without the time?|||Hi
GETDATE() / CURRENT_TIMESTAMP will return the current date and time.
CONVERT(CHAR(8), GETDATE, 112) will return the date.
CONVERT(CHAR(12), GETDATE, 114) will return the time.
Regards
Mike
"Arne" wrote:

> I believe set @.today=getdate will give me the current time.
> How can I get the system date without the time?|||Arne,
If you want the date in ISO standard format, you can use the
following:
declare @.tst char(8)
set @.tst = convert(char(8),getdate(),112)
print @.tst
Look up the CONVERT function in BOL.
On Mon, 21 Feb 2005 06:35:13 -0800, "Arne"
<Arne@.discussions.microsoft.com> wrote:

>I believe set @.today=getdate will give me the current time.
>How can I get the system date without the time?

No comments:

Post a Comment