Access SQL View Tranlate to SQL

Aliq2014

New Member
Joined
Sep 10, 2014
Messages
46
Does anyone know how can I translate the below code from access into SQL?

SELECT dboEmp.FULL_NM, dboEmp.ID, dboEmp.WORK_LOC_NM, dboEmp.SUPPORT_LOC_NM, CDate(Int(([dbo_JLJOURN]![Local_DT]/60/60-5)/24+DateValue("1/1/1990"))) AS Expr1, dboEmp.PERIOD, dboEmp.TYPE_CD, dbo_Door_Group_Location.LOC_BLD_CD
FROM (dbo_JLJOURN INNER JOIN ((dbo_Group_Member INNER JOIN dbo_Groups ON dbo_Group_Member.Group_ID = dbo_Groups.Group_ID) INNER JOIN dbo_Door_Group_Location ON dbo_Groups.Group_Name = dbo_Door_Group_Location.MONITORING_GRP_DESC) ON dbo_JLJOURN.Int_Data1 = dbo_Group_Member.Object_ID) LEFT JOIN dboEmp ON dbo_JLJOURN.User_PID = dboEmp.PERSON_ID
GROUP BY dboEmp.FULL_NM, dboEmp.ID, dboEmp.WORK_LOC_NM, dboEmp.SUPPORT_LOC_NM, CDate(Int(([dbo_JLJOURN]![Local_DT]/60/60-5)/24+DateValue("1/1/1990"))), dboEmp.PERIOD, dboEmp.TYPE_CD, dbo_Door_Group_Location.LOC_BLD_CD
HAVING (((CDate(Int(([dbo_JLJOURN]![Local_DT]/60/60-5)/24+DateValue("1/1/1990"))))>#1/31/2015#) AND ((dboEmp.PERIOD)=#7/31/2015#));
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
That looks like Access SQL to me.

Ah ... looks like you are running the tis Access SQL against an MS SQL Server (MS SS) database.

Note:
SQL = Structured Query Language. Most Relational Database engines (Access, MS SQL Server , mySQL, Oracle, etc) all use a version of SQL for querying their database.

TIP: Microsoft SQL Server's flavor of SQL is called Transact-SQL or T-SQL. So when you search the web you want T-SQL not just SQL.

I think what you are wanting is to translate the Access SQL to Transact-SQL (T-SQL) for Microsoft SQL Server.

To help with learning T-SQL see:

MSDN: CAST and CONVERT (Transact-SQL)


Cast and Convert - Date/time
 
Upvote 0
I *think* you want:
Rich (BB code):
SELECT     dboemp.full_nm, 
           dboemp.id, 
           dboemp.work_loc_nm, 
           dboemp.support_loc_nm, 
           Dateadd('s', ( [local_dt] / 60 / 60 - 5 ) / 24, '1990-01-01') AS expr1, 
           dboemp.period, 
           dboemp.type_cd, 
           grpmember.loc_bld_cd 
FROM       dbo_jljourn 
INNER JOIN 
           ( 
                      SELECT     loc_bld_cd, 
                                 object_id 
                      FROM       dbo_group_member 
                      INNER JOIN dbo_groups 
                      ON         dbo_group_member.group_id = dbo_groups.group_id 
                      INNER JOIN dbo_door_group_location 
                      ON         dbo_groups.group_name = dbo_door_group_location.monitoring_grp_desc) grpMember
ON         dbo_jljourn.int_data1 = grpmember.object_id 
LEFT JOIN  dboemp 
ON         dbo_jljourn.user_pid = dboemp.person_id 
GROUP BY   dboemp.full_nm, 
           dboemp.id, 
           dboemp.work_loc_nm, 
           dboemp.support_loc_nm, 
           Dateadd('s', ( [local_dt] / 60 / 60 - 5 ) / 24, '1990-01-01') dboemp.period, 
           dboemp.type_cd, 
           grpmember.loc_bld_cd 
HAVING     ( ( 
                                 dateadd('s', ( [local_dt] / 60 / 60 - 5 ) / 24, '1990-01-01')) > '2015-01-31' ) 
AND        ( ( 
                                 dboemp.period ) = '2015-07-31' ) );

But I can't really tell what your calculations are supposed to be doing
 
Upvote 0

Forum statistics

Threads
1,221,848
Messages
6,162,404
Members
451,762
Latest member
Brainsanquine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top