开发者

Access SQL Query Help

I have a query in which I need to perform using three entities listed below:

  1. LU_AppName
  2. SDB_AppHistory
  3. SDB_Session

LU_AppName has field APPNAM, SDB_AppHistory has the field STARTTIME which is date/time and also SDB_Session has field DURATION.

I need to run an SQL query to show me Citrix APPLICATIONS which have not been used in the last 6 months.

At the moment I have the code below.

SELECT dbo_LU_APPNAME.APPNAME, dbo_SDB_APPHISTORY.STARTTIME
FROM dbo_LU_APPNAME INNER JOIN dbo_SDB_APPHISTORY ON dbo_LU_APPNAME.PK_APPNAMEID =开发者_StackOverflow dbo_SDB_APPHISTORY.FK_APPNAMEID
WHERE (((dbo_LU_APPNAME.APPNAME) Like "* Citrix") AND ((dbo_SDB_APPHISTORY.STARTTIME) Between DateAdd("d",-180, Getdate())))

I am a bit confused as I am not very good with SQL

Can anyone please advice, if you require more info please let me know.

Thanks, any help would be greatfull.


Well you're missing 1/2 of the BETWEEN clause...

AND ((dbo_SDB_APPHISTORY.STARTTIME) Between GetDate() AND DateAdd("d",-180, Getdate())


You can use Date() instead of GetDate:

DateAdd("d",-180, Date())

Date() is quite happy with:

Date()-180

DateAdd will accept "m", if you wish to consider months:

DateAdd("m",-6, Date())

Watch out for date formats and locale.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜