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)
 dated

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2003-06-23 : 03:56:36
I've just read http://www.murach.com/books/sqls/article.htm and was rather alarmed. Does anyone have any comments on this?

When I use a select query with dates in the where clause I tend to use ISO format (CCYYMMDD) as I find this the easiest to enter. I presume from the article that I need to enter times too. My problem is that I don't know how to enter times in this format.

thanks

steve

Steve no function beer well without

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2003-06-23 : 04:04:51
As the Hitch Hikers guide says "DON'T PANIC"

Arnold Fribble has an elegant solution for Date without time queries....


SELECT DATEADD(d,0,DATEDIFF(d,0,GETDATE()))


Just replace the "getdate" function with your column name and see what happens....

DavidM

"SQL-3 is an abomination.."
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2003-06-23 : 04:31:43
That works, but I prefer it the other way around -- otherwise it goes funny if you use months or whatever

SELECT DATEADD(d,DATEDIFF(d,0,GETDATE()),0)

 
See http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25897 for some comments on the article.


Edited by - Arnold Fribble on 06/23/2003 04:33:30
Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2003-06-23 : 04:45:28
It did seem a little strange when I wrote it...but I couldn't put my finger on it..

Thanks for the refresher Arnold.

DavidM

"SQL-3 is an abomination.."
Go to Top of Page
   

- Advertisement -