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
 Transact-SQL (2000)
 Current date

Author  Topic 

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-04-27 : 12:46:45
Hi all

how to get current date in sql?


thanks

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-04-27 : 12:48:42
Is this a homework question?

SELECT GetDate() as 'Current Date'


Dinakar Nethi
SQL Server MVP
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-04-27 : 12:50:13
Thanks
No, its not homework
I was getting this with time
So i was about to edit it, current date without time
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2007-04-27 : 12:58:16
Try:
SELECT DATEADD(DAY, 0, DATEDIFF(DAY, 0, GETDATE()))
SELECT DATEADD(DAY, 0, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP))
Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-04-27 : 13:06:13
Thanks
I got it as
select convert(varchar, getdate(), 1)
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-27 : 13:32:50
quote:
Originally posted by reflex2dotnet

Thanks
I got it as
select convert(varchar, getdate(), 1)



that doesn't return a date, it returns a VARCHAR.



- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-04-27 : 13:36:42
Thanks for making that clear.
One question, so cant i use the above returned varchar, for my further part of SP?, like with this i am calculating some dates?
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-27 : 13:41:12
No, you can't. Lamprey already showed you how to remove the time portion from your datetime, and still keep it the proper datatype. Did you try it?



- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-04-27 : 13:42:36
YES, I TRIED THAT
i WILL CHANGE THE REMAINING PART OF MY SP WITH THAT RESULT
THAKS VERY MUCH FOR POINTING OUT THIS

THANKS
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-04-27 : 14:20:54
Great, best of luck, glad we could help!

-Jeff

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -