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 2005 Forums
 Transact-SQL (2005)
 Convert from Access to SQL Server

Author  Topic 

JezLisle
Posting Yak Master

132 Posts

Posted - 2009-03-26 : 06:53:28
I am looking to convert this query in Access into SQL Server, how could I go about this?


SELECT Max([CDV_PATIENTS].[DATA_START_DATE]) AS MaxOfDATA_START_DATE,
Date() AS TodayDate,
IIf([MaxOfDATA_START_DATE]=(Date()-1),"Yes","No") AS Message
FROM CDV_PATIENTS

JezLisle
Posting Yak Master

132 Posts

Posted - 2009-03-26 : 07:24:44
I have read and found this, below, but my problem is the date uses the Time aswell, I need to show the GetDate as dd/mm/yyyy 00:00:00


SELECT MAX([CDV_PATIENTS].[DATA_START_DATE]) AS MaxOfDATA_START_DATE,
GETDate()-1 AS TodayDate,
CASE
WHEN (MAX([CDV_PATIENTS].[DATA_START_DATE]) =(GETDATE()-1)) THEN 'Yes'
ELSE 'No'
END AS TEST
FROM CDV_PATIENTS


How can I do this?
Go to Top of Page

matty
Posting Yak Master

161 Posts

Posted - 2009-03-26 : 08:05:46
SELECT DATEADD(DAY,0,DATEDIFF(DAY,0,GETDATE())) will give date without time.
Go to Top of Page
   

- Advertisement -