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)
 Function to add 23:59:59 to date

Author  Topic 

researcy
Starting Member

6 Posts

Posted - 2007-11-13 : 16:31:04
In my queries I often have a date range from the first of the month to the last day. The problem is that the db codes the time in with the date. To get the range I want, I have to tell it from the 1st day to the 1st day of the next month (which it sees as 0:00 time. How can I add 23:59:59 to the second date? Is there a function to do this?

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-11-13 : 16:37:45
It is best to do date range queries like this: Date greater than or equal to start datetime and date less than end datetime.

Example to select data for October, 2007:

Select
*
From
Mytable
Where
Datecolumn >= '20071001' and
Datecolumn < '20071101'


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -