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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP WITH DATE

Status
Not open for further replies.

gradinumcp

IS-IT--Management
Apr 6, 2005
85
US
Hi there! I am trying to get a report for the current year. So i thought:

(1) I could get Today's Date from the computer clock
(2) Get the year from it.
(3) Then in my SQL database "DateStamp" column, check if the Datestamp has Date Like the year from the clock.

I dont know if this logic makes sense or is there an easy way to get the year's report until the end of the year and once the new year starts, it should show data for the next year.

Here's my sql query:

mysql="SELECT SUM(LeaveHours)/60 AS SUM FROM TimeReport WHERE UserID='911' and LeaveType='Vacation' and DateStamp LIKE '%Year()%'"

What kind of code will go in place of the red code???
 
you mean...

DateStamp LIKE 'YEAR(getdate())' "

Also look at Convert() function...

-DNG
 
Thanks a Bunch..I also found

DATEPART(yyyy,DateStamp) = DATEPART(yyyy,GETDATE())

which also kinda works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top