GROUP BY Hour Portion of Date
Hi,
I'm trying to execute a query in which I need to group by the hour portion of the date.
Example:
Date in DB: 09/18/2008 17:30:00, 09/18/2008 17:00:00
I need to group all values for 09/18/2008 17:00:00 to 09/18/2008 17:59:59
Can this be done within SQL? I tried looking into the CONVERT command but I couldn't get it to work. I don't think it converts the date to just the hour and disregards the minute and seconds.
Any help will be much appreciated.
Thanks!
SQL related questions are best to be asked at a forum devoted to SQL.
Anyway, I have no idea how to do it with Sybase as I've never used it. With for example MySQL you can just use the [HOUR()|http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html] function. E.g.SELECT HOUR(dateTimeOrTimestampColumnName) FROM tableNameHere is a forum devoted to Sybase, you might have more luck over there: [http://www.mydatabasesupport.com/forums/sybase/].
Similar Messages
-
How to show purchasing group members in the item data of the shopping cart?
Dear Experts,
for s shopping cart in SRM 7.0 CS, i have the following business requirement:
In the item data tab of the line item details, the drop down field for Purchasing group is there. Right to this field, there is also a link called "Show members".
If i go on this link, than a small table opens that obviously is there to contain such additional information about the purchasers like name, telephone nummber or extension.
Currently, this small table does not contain any of this additional information for any of the used purchasing groups.
Can you please help me understand, how and where i can maintain this information in the sytem, so it shows in the shopping cart?
Thank you very much for your help.Hi,
thank you very much for the answer.
Actually, the question is not how to create the organizational unit of purchasing group in the PPOMA. This is all done. I just would like to understand, whether there is somewhere a place where i can maintain the name and maybe also the phone number of the buyer himself.
Thus, i would hope to see these details (i.e. the name and the phone number) in that small table that opens up if i click on the "Show members" link that is situated right to the purchasing group field in the "Item data" tab of the details of the line item.
Thank you. -
Hi!
Win 8.1 pro, domain workstation. How Block all access, except for a fews users/groups and domain controller information/date.
Nuance:
From domain AD is locked Workstation Firewall "Domain profile" edit.
Possible?
cenubitHi GirtsR,
I am not sure the command to use the SID to accomplish what you want to achieve, if you only know the SID, you could take use Powershell to find the related information, more information, please check:
Working with SIDs
And a similar thread for reference:
How to find user/group known only SID
More reference: Default local groups.
Best regards
Michael Shao
TechNet Community Support -
How can i clear the portion of data and load the new data in ASO App 9.3.1?
Hi
I want to delete the portion of data and i want to reload the new portion of that data In ASO Application 9.3.1 Version.
Please give anyone with good procedure.
Thanks
KranthiHave a read of :- Clear Data by Fix
Cheers
John
http://john-goodwin.blogspot.com/ -
Change account groups in vendor/ customer master data
Hi,
Do you think is possible to change account groups in vendor/ customer master data?
ThanksHi,
Good evening and greetings,
Changing the account groups will redetermine the Reconciliation account, which will be creating a chaos during Audit Reconciliation. But if there is a requirement, please go through the following link
http://help.sap.com/saphelp_47x200/helpdata/en/dd/55f534545a11d1a7020000e829fd11/frameset.htm
Please reward points if found useful
Thanking you
With kindest regards
Ramesh Padmanabhan -
No. of hours appear in Date Format in Reports
The output of the Personnel Action Report shows the "Annual Working Hours" column in Date format. This is the same with other reports like the Wage Type Reporter.
Can somebody suggest a solution to this?
Thanks
RSHey thanks to both of you for responding.
Personnel Action Report is customised "ZHRPA" and Wage type report is also a customised one.
Ameet, could you please let me know what exactly I am supposed to chekc in my parameters (SU3)? Should I ask the developer to check the report since this is a customised one?
Remi, wage type reporter is also a customised report here. It is the customised version of PC00_M99_CWTR. -
Group by hour and get percentage of value on a particular
Hi All,
Oracle 11g
create table test_table_2 ( time_log TIMESTAMP(6), status number, names varchar2(500) );
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'7'hour ,1,'FN:Will,LN:Smith');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'7'hour ,0,'FN:Will,LN:Paul');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'7'hour ,0,'FN:Will,LN:Liza');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'7'hour ,0,'FN:Will,LN:June');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'6'hour ,0,'FN:Ann,LN:Smith');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'5'hour ,0,'FN:John,LN:Blair');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'4'hour ,1,'FN:Peter,LN:Lloyd');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'3'hour ,1,'FN:Sam,LN:Smith');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'2'hour ,0,'FN:Will,LN:Smith');
insert into test_table_2 (time_log,status,names) values(systimestamp - INTERVAL'1'hour ,0,'FN:Will,LN:Smith');
In the above record I want to see the percenatge of status coulmn being 1 for a given hour.
In other words in the above table
curtime - 7 should give 25%
curtime - 6 should give 0%
curtime - 5 should give 0%
curtime - 4 should give 100%
Currently I am doing two queries
1. grouping by hour for status being 1 and
2. grouping by hour for status being 0
and then calculating the percentage on java level.
I thought it will be lot simpler if it can be done in one shot in sql itself.
Appreciate your help with this.
_PeteWell, i wasn't sure what happened to curtime - 3, curtime -2 and curtime -1 ... but maybe this is a start for you.
create table test_table_2 ( time_log TIMESTAMP(6), status number, names varchar2(30) );
declare
l_timestamp timestamp := systimestamp;
begin
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'7'hour ,1,'FN:Will,LN:Smith');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'7'hour ,0,'FN:Will,LN:Paul');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'7'hour ,0,'FN:Will,LN:Liza');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'7'hour ,0,'FN:Will,LN:June');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'6'hour ,0,'FN:Ann,LN:Smith');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'5'hour ,0,'FN:John,LN:Blair');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'4'hour ,1,'FN:Peter,LN:Lloyd');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'3'hour ,1,'FN:Sam,LN:Smith');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'2'hour ,0,'FN:Will,LN:Smith');
insert into test_table_2 (time_log,status,names) values(l_timestamp - INTERVAL'1'hour ,0,'FN:Will,LN:Smith');
end;
ME_XE?select
time_log,
count(case when status = 1 then 1 else null end) / count(*) * 100
from test_table_2
group by time_log
order by time_log asc;
TIME_LOG COUNT(CASEWHENSTATUS=1THEN1ELSENULLEND)/COUNT(*)*100
07-APR-10 08.46.22.557850 AM 25
07-APR-10 09.46.22.557850 AM 0
07-APR-10 10.46.22.557850 AM 0
07-APR-10 11.46.22.557850 AM 100
07-APR-10 12.46.22.557850 PM 100
07-APR-10 01.46.22.557850 PM 0
07-APR-10 02.46.22.557850 PM 0
7 rows selected.
Elapsed: 00:00:00.15 -
Group by MM/YYYY when date = mm/dd/yyyy
Post Author: misslora
CA Forum: Formula
I want to group data by employee first, then mm/yy and within that group count data by specific code. The Date field in the db is mm/dd/yyyy.
I create group by employee first, then date, second group by items. I formatted the date field to be mm/yyyy, then counted the items and placed that in the group footer for the date group.
Expected Results:
SMITH: Jan-07 mufflers = 10, wipers = 5
JONES: Jan-07 mufflers 3, wipers 2
Feb-07 mufflers = 5, wipers = 2, tires = 10
Actual Results:
Smith: Jan 07 mufflers = 5, wipers = 2
Jan 07 mufflers = 5, wipers = 3
I need to actually convert the mm/dd/yyyy field to a true MM/YY field.
Thanks for any help you can give.Post Author: DellS
CA Forum: Formula
You don't really need the variable - create a formula that reads:
ToText({table.datefield}, 'yyyyMM')
Group by this formula. The format string IS CASE SENSITIVE!
You want to have year first so that you get your data in true date order. You can display the the month name, but you need to use the month number for your group for the same reason. Because this is a string, to have your months come out in the correct order instead of 1, 10, 11, 12, 2, 3... you need to have a leading zero on it.
-Dell -
Hi all,
I need to ask how to calculate a portion of data from an essbase cube. I have extracted a portion of data from my cube and need to import back and then calculate.
For Example, this is the area that I extracted data from in a report script
<ROW ("Measures", "Time", "Year", "Scenarios", "Version", "Customers", "Products")
//Meaesures
Administrative Promotion "Business Development"
"Royalty Revenue"
//Time
<CHILD Q1 <CHILD Q2 <CHILD Q3 <CHILD Q4
//Year
&CurrYr &NextYr &NextYr1 &NextYr2 &NextYr3 &NextYr4
//Scenarios
Forecast
//Version
"Work 1"
//Customers
"All Customers"
//Products
"888.88.8" "949.69.1" "888.89.8"
Ho do I calculate the above areas from each of the dimensions?
Thanks a lotSo if I have more scripts in the same report file that extract data from other areas of these dimensions then I will do something like this?
FIX("Accounts 1", "Business Development","Royalty Revenue", "Measures1", "Measures2", &CurrYr, &NExtYr1, &NextYr2,&NextYr3,&NextYr4, Forecast, "Scenario1", "Scenario2", "Work 1", "888.88.7", "888.88.8", "949.69.1", "888.89.8", "All Products")
CALC DIM (TIME, CUSTOMERS, Agreements)
ENDFIX
i-e just keep adding the members from the above dimensions? and the ones that are dynamic calcs need to be calculated here as well? or can we leave it till they are retrieved?
Thanks for your help. -
Recently my iphone is consuming too much data, I have installed a data monitoring app and I found that - although I turned off all notifications and push email - push services is using around a 1mega/hour from cellular data (even if I am using wi-fi) !!!
cpupower frequency-info
analyzing CPU 0:
driver: acpi-cpufreq
CPUs which run at the same hardware frequency: 0 1 2 3
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 10.0 us.
hardware limits: 800 MHz - 2.30 GHz
available frequency steps: 2.30 GHz, 2.30 GHz, 1.80 GHz, 1.60 GHz, 1.40 GHz, 1.20 GHz, 1000 MHz, 800 MHz
available cpufreq governors: conservative, powersave, ondemand, performance
current policy: frequency should be within 800 MHz and 2.30 GHz.
The governor "conservative" may decide which speed to use
within this range.
current CPU frequency is 800 MHz.
cpufreq stats: 2.30 GHz:0,02%, 2.30 GHz:0,05%, 1.80 GHz:0,05%, 1.60 GHz:0,03%, 1.40 GHz:0,01%, 1.20 GHz:0,16%, 1000 MHz:0,38%, 800 MHz:99,29% (1017)
boost state support:
Supported: yes
Active: yes
25500 MHz max turbo 4 active cores
25500 MHz max turbo 3 active cores
25500 MHz max turbo 2 active cores
25500 MHz max turbo 1 active cores
Thax -
Get number of hours between two dates and two hours using factory calendar
Hello all,
I have the following requirement: I need to calculate the number of hours between two dates and two hours (start date- finish date and start hour-finish hour) or timestamps using a factory calendar. I must program it on CRM environment.
Does anybody know a function module that makes it?
Thanks in advance.
CarmenPlease check function module DURATION_DETERMINE.
- April King -
Hello,
I have at table with a date field (dd/mm/yyyy hh)
How do I group by hh ?
I want something like the below:
SELECT TRUNC(DATE_FIELD) COUNT(*)
FROM MYTABLE
GROUP BY TRUNC(DATE_FIELD);
but this will group by dd/mm/yy
I need the same query but group by dd/mm/yyyy hh
Thank you in advance.Hi,
drbiloukos wrote:
Hello,
I have at table with a date field (dd/mm/yyyy hh)
How do I group by hh ?
I want something like the below:
SELECT TRUNC(DATE_FIELD) COUNT(*)
FROM MYTABLE
GROUP BY TRUNC(DATE_FIELD);
but this will group by dd/mm/yy
I need the same query but group by dd/mm/yyyy hh
Thank you in advance.TRUNC (d) with only 1 argument is the same as
TRUNC (d, 'DD'): it maps all DATEs in the same calendar day to the first DATE in that day.
TRUNC (d, 'HH') maps all DATEs in the same hour to the first DATE in that hour.
SELECT TRUNC (DATE_FIELD, 'HH') AS hr
, COUNT (*) AS cnt
FROM MYTABLE
GROUP BY TRUNC (DATE_FIELD, 'HH')
; -
Can not view/export a report which has 2 group by field when no data found
Recently I developed a report, which contains 2 group by fields. it runs successfully when the report displays some data.
but when there is no data, i cann't view/export this report.
It shows nothing by html format and shows "this file cannot be opened because it has no pages" message by pdf format.
even there is no records for this report, i still want to see the template file and show some basic information.
please help me.
DanielI've found that, just like I used to do in Oracle Reports, if you put in a COUNT column to count your returning rows, you can put 'No Data Found' when there's no data. That way, your report will return and not error out.
For .pdfs, this is the code I use; COUNT with code of <?if:count(field_name)=0?>.
In the .rtf..
COUNT
No Data Found
END COUNT
Put this in the .rtf before your data should appear or else it won't work.
Hope this helps!
Kris -
Index File group on same drive as data files
I've just found a file group used for indexes on the same drive as the data files.
Am i correct in saying there is little benefit to this. The index file group should be on it's own spindle?
Mr Shaw... One day I might know a thing or two about SQL Server!Definitely there will be performance gain provided you are querying for related data which as references index on those index filegroups.
It helps in parallel processing , having data and index on multiple disk heads helps in reading the data parallel. For more information you can refer the below link
https://technet.microsoft.com/en-us/library/ms190433%28v=sql.105%29.aspx
--Prashanth -
Group by month/year from DATE FORMAT column
Hi Chaps,
I have a recordset that pulls data from a database, then presents the data in a table. The data is grouped by 'projid', repeated for every 'projid', with a show/hide control, to show all the 'jobid's' relating to that particular 'projid'
This is what I have so far:
Code:
SELECT
tbl_projects.projid,
tbl_projects.projtitle,
tbl_projects.projdue, DATE_FORMAT(tbl_projects.projdue, '%%d/%%m/%%Y') as projdue_format,
tbl_projects.projtype,
tbl_projects.projinvtype,
tbl_projects.FK_custid,
tbl_projects.projcompletedate
tbl_languaget.langtname,
tbl_doctype.doctypename,
tbl_jobs.jobid,
tbl_jobs.FK_projid,
tbl_jobs.jobname,
tbl_jobs.FK_langid,
tbl_jobs.jobpages,
tbl_jobs.jobshipped,
tbl_jobs.jobinvsent,
tbl_jobs.jobtranslatorcharge,
'tbl_jobs' as fromtable,
tbl_customers.custid,
FROM tbl_projects
INNER JOIN tbl_jobs
ON tbl_projects.projid=tbl_jobs.FK_projid
INNER JOIN tbl_languaget
ON tbl_languaget.langtid=tbl_jobs.FK_langid
INNER JOIN tbl_customers
ON tbl_customers.custid=tbl_projects.FK_custid
INNER JOIN tbl_costs
ON tbl_costs.FK_custid=tbl_customers.custid
INNER JOIN tbl_doctype
ON tbl_doctype.doctypeid=tbl_jobs.FK_doctypeid
WHERE tbl_projects.projstatus='Complete'
AND tbl_projects.projinvtype='Costing Sheet'
AND langtname!='TH'
AND langtname!='ID'
AND langtname!='KO'
AND langtname!='JP'
AND jobinvsent='y'
AND FK_custid = %s
ORDER BY projid ASC", GetSQLValueString($colname_rsInvPending, "int");
$rsInvPending = mysql_query($query_rsInvPending, $conndb2) or die(mysql_error());
//$row_rsInvPending = mysql_fetch_assoc($rsInvPending);
$totalRows_rsInvPending = mysql_num_rows($rsInvPending);
Code:
// REPEAT - FOR EVERY PROJECT
<?php
$previousProject = '';
if ($totalRows_rsInvPending > 0) {
// Show if recordset not empty
while ($row_rsInvPending = mysql_fetch_assoc($rsInvPending)) {
if ($previousProject != $row_rsInvPending['projid']) {
// for every Project, show the Project ID
?>
Code:
// SHOW/HIDE CONTROL
<tr>
<td colspan="9" class="highlight"><span class="blueBold"><a href="#" onclick="toggle2('proj1<?php echo $row_rsInvPending['projid'] ?>', this)"><img src="../../Images/plus.gif" border="0" /></a> <?php echo $row_rsInvPending['projid'] ?> - </a></span><span class="blueNOTBold"><em><?php echo $row_rsInvPending['projtitle'] ?></em></span></td>
</tr>
Code:
// SHOW/HIDE
<?php $previousProject = $row_rsInvPending['projid']; } ?>
<tr class="proj1<?php echo $row_rsInvPending['projid'] ?>" style="display:none">
<td>column 1</td>
<td>column 2</td>
What I want, is to put in another grouped by stage, where the 'projid's' themselves are in a show/hide region, grouped by 'projcompletedate' (year/month). 'projcompletedate' is in DATE format, but how to I get PHP/SQL to take the month and year and then group them correctly?Hi David, I'm not sure if I've got this right, would you mind looking at my latest code?:
<table border="0" cellpadding="0" cellspacing="0" id="tblinvoice">
<tr>
<th>Job Title</th>
<th>Type</th>
<th>Language</th>
<th>Translator</th>
<th>Total</th>
<th>Full</th>
<th>Fuzzy</th>
<th>Proof</th>
<th>Full Price</th>
<th>Discount Price</th>
<th>Document Format</th>
<th>Pages</th>
<th>Typesetting Cost</th>
<th>EN Proofreading Cost</th>
<th>Total</th>
<th>Translator Charge</th>
<th>Profit</th>
<th>Profit Percentage</th>
</tr>
<?php
$previousMonth = '';
if ($totalRows_rsInvPending > 0) {
// Show if recordset not empty
do ($row_rsInvPending = mysql_fetch_assoc($rsInvPending)) {
if ($previousMonth != $row_rsInvPending['themonth']) {
// for every Month, show the Month Name
?>
<tr>
<td colspan="18" class="highlight"><?php echo $row_rsInvPending['theyear'] ?> - <?php echo $row_rsInvPending['themonth'] ?></td>
</tr>
<?php $previousMonth = $row_rsInvPending['themonth']; } ?>
<?php
$previousProject = '';
if ($totalRows_rsInvPending > 0) {
// Show if recordset not empty
while ($row_rsInvPending = mysql_fetch_assoc($rsInvPending)) {
if ($previousProject != $row_rsInvPending['projid']) {
// for every Project, show the Project ID
?>
<tr>
<td colspan="18" class="highlight"><span class="blueBold"><a href="#" onclick="toggle2('proj1<?php echo $row_rsInvPending['projid'] ?>', this)"><img src="../../Images/plus.gif" border="0" /></a> <?php echo $row_rsInvPending['projid'] ?> - </a></span><span class="blueNOTBold"><em><?php echo $row_rsInvPending['projtitle'] ?></em></span></td>
</tr>
<?php $previousProject = $row_rsInvPending['projid']; } ?>
<tr class="proj1<?php echo $row_rsInvPending['projid'] ?>" style="display:none">
<td><?php echo $row_rsInvPending['jobname']; ?></td>
<td><?php echo $row_rsInvPending['projtype']; ?></td>
<td><?php echo $row_rsInvPending['langtname']; ?></td>
<td><?php echo $row_rsInvPending['translator']; ?></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<?php } while ($row_rsInvPending = mysql_fetch_assoc($rsInvPending)); ?>
<?php } // Show if recordset not empty ?>
Maybe you are looking for
-
HT201413 Why can't I get Home Sharing to show up in my Itunes?
I have three computers authorized on my Home Sharing, but when I call up Itunes on any of the computers, Home Sharing computers do not show up. Can someone help me. I just got a new computer and can't seem to get my Itunes library switched over.
-
How to get preq item number in a PM and/or PS component
I need to access the preq item when opening a component in a PM Work Order or in PS. I need to access this information in EXIT_SAPLEBND_001 but ceban does not contain this so I need to access it as I open the component and save into memory. I have
-
Hi All, My scenario is Proxy to File scenario. I used content conversion for generating flatfile in receiver side. In FCC i used fieldFixed Lengths, The flatfile is generated. I gave the Target Directory as AL11 directory(NFS). In my scenario length
-
What size photoshop file for 16:9?
This is a great site and I've been doing alot of searching/reading and trying to get some info. Maybe I've misunderstood some of the answers but I'd just like someone to confirm my suspicion: What pixel dimensions do my photoshop files need to be if
-
How to get the iView Property value in NWDS
Hi all, I my requirement I need to get some of the iView Property Value in NWDS. Can anybody help me for this? Helpful answers will appreciate. Thanks & regards, Kathiresan R