Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

to get only date or hour from getdate()

Status
Not open for further replies.

oigo

Programmer
Apr 27, 2002
23
CO
Hello, the getdate() returns the date and the hour of the system, but I need to get only the date using getdate(). how to? thank
 
Select DateOnly=
Convert(datetime, int(getdate()))

Select DateOnly=
Convert(datetime, Convert(char(10),getdate(),101))

Select HourOnly=
Hour(getdate())

Select HourOnly=
Datepart(hh,getdate())

Select TimeOnly=
Convert(char(8),getdate(),8)
Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top