Fiat Coupe Forum
- Funded by the Club for the benefit of all owners
- Please consider joining the Club to help keep the Forum running
- Or you can choose to make a Donation
Fiat Coupe Club UK
join the club
Fiat Coupe Forum
 
» Announced
    Posting images


» Related sites
    Main club site
    fiatcoupe.net

 
Who's Online Now
1 registered members (1 invisible), 164 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Forum Statistics
Forums48
Topics103,648
Posts1,169,475
Members1,618
Most Online39,516
Apr 16th, 2026
Top Posters(All Time)
barnacle 33,794
stan 32,123
Theresa 23,346
PeteP 22,266
bockers 21,083
Edinburgh 18,725
JimO 17,919
Nigel 17,386
Previous Thread
Next Thread
Print Thread
SQL ish help required #1643182
05/08/2020 15:55
05/08/2020 15:55

E
elder81
Unregistered
elder81
Unregistered
E



Hi all,

I have written the following simple SQL and it works perfectly:

Select orgunit.shortname as 'Store', datepart(wk, schedulekpiday.dayId) as 'Week Number', schedulekpiday.DayID as 'Date', KPI.shortname, schedulekpiday.Value * 100 as 'Efficiency Score'
from schedulekpiday
inner join KPI
on schedulekpiday.KpiId = kpi.KPIID
inner join orgunit
on orgunit.orgunitid = schedulekpiday.orgid
where --schedulekpiday.orgId = 1533 and schedulekpiday.DAYID between '2020-08-10' and '2020-08-16'and
KPI.KPIId = 244

In the software I work with we have a report writer that generates columns based on the SQL.

The report writer is getting confused when using the datepart fucntion, instead of creating one column, it create 2.

Any ideas how to stop this happening, perhaps another method of getting week number from a date that doesn't require an additional ,?

Thanks

Mark

Re: SQL ish help required [Re: ] #1643229
06/08/2020 15:25
06/08/2020 15:25
Joined: Dec 2005
Posts: 12,309
Sandhurst
Begbie Offline
ex El Presidente
Begbie  Offline
ex El Presidente
I AM a Coop

Joined: Dec 2005
Posts: 12,309
Sandhurst
I'm guessing the S/W is seeing the , as the separator, so would it some how be able to work this calculation out into a variable, then call the variable in the SQL query?


Originally Posted by Jonny - After being taken out at Spa
Your car is Usain Bolt with wellies
Re: SQL ish help required [Re: ] #1643235
06/08/2020 18:50
06/08/2020 18:50
Joined: Dec 2006
Posts: 3,929
The Faringdon Folly
O
oxfordSteve Offline
Forum is my job
oxfordSteve  Offline
Forum is my job
O

Joined: Dec 2006
Posts: 3,929
The Faringdon Folly
Apologies is you have tried this, but is the DayID the correct datatype in all referenced tables? If you substitute GetDate(), for s.dayID in the datepart function, does it work correctly??
Could you write a wrapper function in SQL that takes a date as the only argument returns the week number ?

Is it a known issue in the Report tool?





Powered by UBB.threads™ PHP Forum Software 7.7.1
(Release build 20190129)
PHP: 7.4.33 Page Time: 0.015s Queries: 14 (0.008s) Memory: 0.5976 MB (Peak: 0.6398 MB) Data Comp: Off Server Time: 2026-07-23 16:46:59 UTC