Any Date function to find date on last friday?
Hi all,
Is there any date function module to find out the date on last friday....
And one more thing....any function module to findout the range of dates for the last week...(i.e) date from last week monday to last week friday.
Thanking u all in advance.
Regards,
Chandra Sekhar
REPORT ZSN_FRIDAYTEST .
data: days type p.
data: date type sy-datum.
parameters: p_date like sy-datum default sy-datum.
*-- Get the last Friday
call function 'DAY_IN_WEEK'
exporting
datum = p_date
IMPORTING
WOTNR = days.
days = days + 2.
date = p_date - days.
write:/ '(Assuming Monday is the first day of the week)'.
write:/ 'Date Entered:', p_date.
write:/ 'Last Friday:', date.
*- Range of dates in last week
data: date1 type sy-datum.
data: date2 type sy-datum.
data: days1 type p.
data: days2 type p.
call function 'BWSO_DATE_GET_FIRST_WEEKDAY'
exporting
date_in = p_date
IMPORTING
DATE_OUT = date1
date1 = date1 - 7.
date2 = date1 + 4.
write:/ 'Range:', date1, '-', date2.
Similar Messages
-
Date function problems with dates from core not recognized as dates
Our core provides dates in two formats: YYYYDDD and MMDDYY (YYYYDDD for today [2/21/12] would be 2012052). We have determined that Crystal Reports is not viewing them as dates, but rather numbers. If querying on just a specific date, no problem. But if I want to use a date function like DayOfWeek, then things don't work.
I need a report to always provide yesterday's data - except on Monday, where it needs to look back at Friday.
I tried a criteria of:
if DayOfWeek(CurrentDate) = 1 then {DDMAST.DATOP7} = CurrentDate - 2 else
if DayOfWeek(CurrentDate) = 2 then {DDMAST.DATOP7} = CurrentDate - 3 else
{DDMAST.DATOP7} = CurrentDate -1
{DDMAST.DATOP7} is the date field from our core.
I tried this but got an error message of "A Number is Required Here" and it highlights the CurrentDate - 2.
Since we believe that Crystal Report is not viewing our dates as dates - but viewing them as numbers, what do I need to do to correct this? Someone suggested I'd need to extract each date portion (month, date, and year) and create variables to "build" a date that Crystal Reports would understand. Any suggestions?Hi,
You're correct. There appears to be two branches in this thread.
To address your issue, Crystal only recognizes actual date types, ie. Months, Days and Years. Your serial date isn't a recognized date type so we have to:
1) Determine which format your date field is
2) Convert your number to a date using the appropriate formatting.
I am assuming your dates will either be 6 (MMddyy) or 7 (yyyyddd) characters long. If there are other patterns you'll need to determine that.
The problem I found is what does your date for today (March 6, 2012) look like in MMddyy format?
Any month before October would never have a leading 0 if your date is stored as a number. So you should take that into account as well using my logic.
I added that into the logic by checking for a length of 5.
NumberVar Full := 030612;
StringVar myDate;
myDate := ToText (Full, 0, "", "");
Select Length (myDate)
Case 5: Date (2000 + ToNumber (myDate [4 to 5]), ToNumber (myDate [1]), ToNumber (myDate [2 to 3]))
Case 6: Date (2000 + ToNumber (myDate [5 to 6]), ToNumber (myDate [1 to 2]), ToNumber (myDate [3 to 4]))
Case 7: Date (ToNumber (myDate[1 to 4]), 1, 1) + (ToNumber (myDate [5 to 7]) - 1)
Default: Date (0, 0, 0);
If you edit the first line and change it to:
NumberVar Full := 2012066;
You will also get today's date. -
Function module find date Range input for scheduling a job
hi i have created a program for scheduling a back ground job for purchase order extract in that i have to get the last 7 days records when i schedule it on every sunday can any one tell me the function module which satisfies the requirment
Date Range input in my program to be calculated for past 7 days from current date (ie from Sunday to Saturday of the week.)Hi,
You can do it simply by
v_cdate TYPE sy-datum, " current system date
v_cdate = sy-datum - 7. " take date 7 days before current date
Pass this v_cdate in your logic
Hope it will help you.
Thanks
Arun Kayal -
PL SQL using date functions to find partitions
I am trying to teach myself PL SQL and can use a bit of help. I am trying to automate the
dropping of paritions.
Can somebody provide me with an example of how to create some code that will return a liist
of partitions that are older than the N number of years (current year 1/1/2011), or N number of
months, weeks or days...
For example, today is 3/4/2011 How would I create code that will find me partitons that are
older than 2/1/2011 (current first of month -1 month, or ciurrent first of month -N months).
My partition names for all my tables are all in this formate P_YYYY_MM-DD
Please keep in mind this query can retrurn no rows, one row or several rows. If nothing is retrurned
I woiuld liike to print that out for each table.
Thanks in advance to all who answerThis would be a combination of sysdate and either add_months(date,number_of_months) or date-number_of_days, along with a conversion of the date to a pattern that matches your partition name format. Fortunately you've chosen a sensible format that sorts correctly.
So for finding the number of partitions older than so-many years:
select count(*)
from user_tab_partitions
where table_name = ... and
partition_name < to_char(add_months(sysdate,-12*5),'"P"_YYYY_MM-DD') Just be careful about whether you want partitions for which the oldest possible date is older than so-many years, or for which the newest possible date is older than so-many years.
Edit: Oh bear in mind that if you select only COUNT(*) then you'll always get a row back even if no matching partitions are found, and COUNT(*) will be 0. If you selected table_name and count(*) then you would get no rows back for tables that have no matching partitions. COUNT(*) never returns null.
Edited by: David_Aldridge on Mar 3, 2011 11:15 PM -
Need function to find date of a day
Hi,
Please advice a query or a function that will get me all the dates of the current year that fall on friday.
Ex: If the query is run the desired output as below
02/01/2009
09/01/2009
16/01/2009
Thank YouThis will work, although it is nls dependent:
select next_day(trunc(sysdate, 'yyyy')-1, 'FRI') + 7*(level-1) friday_dates
from dual
where trunc(next_day(trunc(sysdate, 'yyyy')-1, 'FRI') + 7*(level-1), 'yyyy') = trunc(sysdate, 'yyyy')
connect by level <= 53;
FRIDAY_DAT
02/01/2009
09/01/2009
16/01/2009
04/12/2009
11/12/2009
18/12/2009
25/12/2009 -
Any Database Query to Find User Making Last Edit to Spec
Is there any table in the PLM4P database that records the user PKID for the at least the latest edit on a specification?
We know this information is not presented in the UI. If we can find out if this is recorded anywhere in the database, we can write a query when this info needs to be known.
Our business case is:
The spec originator (author) has left the company, so we have allowed DRAFT edit rights to the entire group and not just the author.
Now we want to determine which group member made a recent change.
Thank you.The commonLifecycleEventLog table should give you the history of each spec in terms of edit/saves.
Details about the table are the following, taken from the Extensibiltiy Pack, Extensiblity Guide, in the Event Model chapter
As specific events occur in GSM and SCRM, their details are captured and recorded in
a single database table. Clients can watch for events added to this table to trigger some
custom actions.
Each event captured may include the following information:
- Event Type—The type of event that occurred (1: Create, 2: Save, 3: Workflow, 4: Copy)
- Event Source—What caused the event (New issue of a specification, workflow
transition, etc.)
- Actor—User who performed the event
- Time—Date and time stamp of when the event happened
- Affected Object—Specification or object that was acted upon (Specification that was
saved, specification that was copied, etc.)
- Related Object—Related object when appropriate (Workflow step, smart issue
request, specification ID, etc.)
- Reason—Reason the action occurred when appropriate (Workflow comments, global
succession reason for change, smart issue request that caused the change, etc.) -
How to find data base tables for a particular trancation code
Dear All,
Is there any T.code for finding data base tables used in a particular transaction code(Eg.: MM01).
Regards,
SatyapalliHello Satya
There is a very useful function module available for your requirement:
<b>RS_PROGRAM_TABLES</b>
Call this function module using:
OBJECT_TYPE = 'TRAN' " transaction
OBJECT_NAME = 'VA01'
" PROGRAM -> not required
MONITOR_ACTIVATE = 'X'
The function module will list you all DB tables touched by the transaction and shows whether they are read or updated (unfortunately, on ECC 5.0 this seems to be no longer the case. All tables are displayed as READ).
Regards
Uwe -
Simple Javascript date() function not executing.
If I open the javascript input window from a button and enter a simple js date function:
vDate = new Date();
alert(vDate();
This code executes flawlessly when the button is clicked.
However, if I place the exact same code in the Execute Advacned Actions javascript window "on enter frame" Action, the alert popup code not exdecute/appear, it will fail silently.
I'm simple trying to get a javascript funtion to execute on... the On Enter Action.
Any suggestions?
ThanksHello,
I just tried the scenario and I can see that JS code is executing properly. I used the same JS as you have given (just corrected the syntax in the second line). So, I create an Advanced action that has this JS, and I assigned that to "On Slide Enter" action of the slide. Other thing that I did is that I chose "current" as the window in the Execute Javascript options.
Ashish -
Condition field in XL Reporter Get Other Data function
I want to use the XL Reporter "Get Other Data" function to get data from a file not in the current Business Partner dimension BPA. Using the SalesPerson code SlpCode, I want to get the SalesPerson Name, SlpName. What is the value for the condition field to restrict the retrieval to just the one record that matches the SlpCode in the BPA dimension? I've tried ocrd.SlpCode=oslp.SlpCode. I've tried SlpCode=oslp.SlpCode. But I either get all the names in the Salesperson file or I get some type of syntax error.
Jim,
When you say I should be able to pass a parameter, do you mean while using the XLR "Get other data" function? I thought that's what I was doing when I filled out the Get other data screen with the userid, password, then I specified the OSLP table, requesting SlpName in the Fields section, and then in Condition, I specified OCRD.SlpCode = OSLP.SlpCode. When the report ran, I got a "#ixGetData error: The multi-part identifier "OCRD.SlpCode" could not be bound". I tried substituting the BPA dimension qualifier, ie: BPA.SlpCode, but got the same error.
If I removed the initial qualifier in the Condition field, ie: SlpCode = OCRD.SlpCode, when I ran the report I got ALL Salespersons names, not just the one that matched the SlpCode field on the current Business Partner line. -
Finder Window Remembering Last Position?
Sometimes when i am working and in say Photoshop or Dreamweaver and i go to find an image from a folder i move through them until i find it.
A few moments later i might need to find something else in that folder.
Is there any way to make finder remember the last folder i was in, via maybe an app?
As sometimes the folder i need to get to is buried in multiple ones.
The only quickest way i can find is to put the folder i am working in into the places areas of the finder window.
I know from the drop down it lists recent places, but only remembers certain instances and not this one...Default Folder X - VersionTracker or MacUpdate.
-
Function to find the Last Date of Month One Year Ago - RETURNS ERROR
I've written sql code which takes a date and finds the Last Day of the Month one year ago. For example, it takes the date '2015-04-17' and returns the date '2014-04-30'. The code works fine in a query. Now I'm trying to turn this into a function. However,
when I try to create the function I get the error:
Operand type clash: date is incompatible with int
Why is this error being returned?
Here is my function:
CREATE FUNCTION dbo.zEOM_LY_D(@Input Date)
RETURNS date
AS
BEGIN;
DECLARE @Result date;
SET @Result = convert(DATE, DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
RETURN @Result;
END;
Thanks for any help you can give.
Stan,
Thanks very much- that does the trick. I should have said I am using SQL 2008 so EOMONTH is not available to me. I still don't get why I got an error though, since I was treating a date like a date and not like an int.
Thanks, John
I think i found the issue but i do not know why it is causing the issue. i think may be the way dates are treated/stored internally..i think dates are stored as no of days after 0001/01/01 but cannot see how this cwould effect..may be somebody else can through
some light.....
if you make it as datetime it will work,
if you leave it as date - eliminate adding 1... you should prefer to use dateadd to add/substract dates.
try this to understand..
--removed the +1 in the code
declare @input date
set @input ='20150503'
select
convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)),0)),101)
go
--made the datatype as datetime
declare @input datetime
set @input ='20150503'
select
convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
Hope it Helps!! -
Query to find the difference between the last date and the second to the last date
Hi all,
Hope all is well.
I am working on the following problem because I am trying to improve my MS SQL skills. But I am stuck at the moment and I wonder if you could provide some assistance please. Here is the issue:
Table 1: Dividends
divId
ExDate
RecordDate
PayDate
Amount
Yield
symId
1
2013-02-19
2013-02-21
2013-03-14
0.23
0.00000
3930
2
2012-11-13
2012-11-15
2012-12-13
0.23
0.00849
3930
3
2012-08-14
2012-08-16
2012-09-13
0.20
0.00664
3930
4
2012-05-15
2012-05-17
2012-06-14
0.20
0.00662
3930
5
2012-02-14
2012-02-16
2012-03-08
0.20
0.00661
3930
6
2011-11-15
2011-11-17
2011-12-08
0.20
0.00748
3930
7
2011-08-16
2011-08-18
2011-09-08
0.16
0.00631
3930
8
2011-05-17
2011-05-19
2011-06-09
0.16
0.00653
3930
9
2011-02-15
2011-02-17
2011-03-10
0.16
0.00594
3930
10
2010-11-16
2010-11-18
2010-12-09
0.16
0.00620
3930
11
2010-08-17
2010-08-19
2010-09-09
0.13
0.00526
3930
12
2010-05-18
2010-05-20
2010-06-10
0.13
0.00455
3930
13
2010-02-16
2010-02-18
2010-03-11
0.13
0.00459
3930
Table 2: Tickers
symId
Symbol
Name
Sector
Industry
1
A
Agilent Technologies Inc.
Technology
Scientific & Technical Instruments
2
AA
Alcoa, Inc.
Basic Materials
Aluminum
3
AACC
Asset Acceptance Capital Corp.
Financial
Credit Services
4
AADR
WCM/BNY Mellon Focused Growth ADR ETF
Financial
Exchange Traded Fund
5
AAIT
iShares MSCI AC Asia Information Tech
Financial
Exchange Traded Fund
6
AAME
Atlantic American Corp.
Financial
Life Insurance
7
AAN
Aaron's, Inc.
Services
Rental & Leasing Services
8
AAON
AAON Inc.
Industrial Goods
General Building Materials
9
AAP
Advance Auto Parts Inc.
Services
Auto Parts Stores
10
AAPL
Apple Inc.
Technology
Personal Computers
11
AAT
American Assets Trust, Inc.
Financial
REIT - Office
12
AAU
Almaden Minerals Ltd.
Basic Materials
Industrial Metals & Minerals
I am trying to check the last date (i.e. max date) and also check the penultimate date (i.e. the second to the last date). And then find the difference between the two (i.e. last date minus penultimate
date).
I would like to do that for each of the companies listed in Table 2: Tickers. I am able to do it for just one company (MSFT) using the queries below:
SELECT
[First] = MIN(ExDate),
[Last] = MAX(ExDate),
[Diff] = DATEDIFF(DAY, MIN(ExDate), MAX(ExDate))
FROM (
SELECT TOP 2 Dividends.ExDate
FROM Dividends, Tickers
WHERE Dividends.symId=Tickers.symId
AND Tickers.Symbol='MSFT'
ORDER BY ExDate DESC
) AS X
Outputs the following result:
First
Last
Diff
2012-11-13
2013-02-19
98
But what I would like instead is to be able to output something like this:
Symbol
First
Last
Diff
MSFT
2012-11-13
2013-02-19
98
AAN
2012-11-13
2012-12-14
1
X
2012-11-13
2012-12-14
1
Can anyone please let me know what do I need to add on my query in order to achieve the desired output?
Any help would be greatly appreciated.
Thanks in advance.Could you try this?
create table Ticker (SymbolId int identity primary key, Symbol varchar(4))
insert into Ticker (Symbol) values ('MSFT'), ('ORCL'), ('GOOG')
create table Dividend (DividendId int identity, SymbolId int constraint FK_Dividend foreign key references Ticker(SymbolId), ExDate datetime, Amount decimal(18,4))
insert into Dividend (SymbolId, ExDate, Amount) values
(1, '2012-10-1', 10),
(1, '2012-10-3', 1),
(1, '2012-10-7', 7),
(1, '2012-10-12', 2),
(1, '2012-10-23', 8),
(1, '2012-10-30', 5),
(2, '2012-10-1', 10),
(2, '2012-10-6', 1),
(2, '2012-10-29', 7),
(3, '2012-10-1', 22),
(3, '2012-10-3', 21),
(3, '2012-10-7', 3),
(3, '2012-10-12', 9)
WITH cte
AS (SELECT t.Symbol,
d.ExDate,
d.Amount,
ROW_NUMBER()
OVER (
partition BY Symbol
ORDER BY ExDate DESC) AS rownum
FROM Ticker AS t
INNER JOIN Dividend AS d
ON t.SymbolId = d.SymbolId),
ctedate
AS (SELECT Symbol,
[1] AS maxdate,
[2] AS penultimatedate
FROM cte
PIVOT( MIN(ExDate)
FOR RowNum IN ([1],
[2]) ) AS pvtquery),
cteamount
AS (SELECT Symbol,
[1] AS maxdateamount,
[2] AS penultimatedateamount
FROM cte
PIVOT( MIN(Amount)
FOR RowNum IN ([1],
[2]) ) AS pvtquery)
SELECT d.Symbol,
MIN(MaxDate) AS maxdate,
MIN(penultimatedate) AS penultimatedate,
DATEDIFF(d, MIN(penultimatedate), MIN(MaxDate)) AS numberofdays,
MIN(MaxDateAmount) AS maxdateamount,
MIN(penultimatedateAmount) AS penultimatedateamount,
MIN(MaxDateAmount) - MIN(penultimatedateAmount) AS delta
FROM ctedate AS d
INNER JOIN cteamount AS a
ON d.Symbol = a.symbol
GROUP BY d.Symbol
ORDER BY d.Symbol
Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers.
Thanks!
Aalam | Blog (http://aalamrangi.wordpress.com) -
Function Module to find date by passign the Planning Calendar
Hi All,
Can you tell me is there any function Module to find date by passign the Planning Calendar?
The requirement is i have a planning calender assigned to the Material in the MRP2 view.
Example: Material XXXXXX is assigned a Planning Calendar Z01.
Z01 is defined such that Delivery is on Monday only. This calendar says that the material is received from the Vendor only on Mondays.
So whenever i punch a Sales Order for Material XXXXXX, a PR is automatically geenrated when saving the sales order and the calculation of Delivery dates is also happening at this level.
Basing on this PR a PO is raised to a Vendor for procuring the Material XXXXXX, now my problem is for example the PO is raised today (30.04.2008), but the Materail XXXXXX is available only on next monday in my plant (05.05.2008) basing on my Planning Calendar assigned in the Materail Master, so i have to inform this dealy to my customer at the time of punching the sales order.
So is there any function Module to find date by passign the Planning Calendar?
Thanks for your valuable inputs.
Regards,
SudarshanHi Jorge,
Thanks for your reply.
I am unable to open the Function module which you have mentioned below.
I am working on 4.6 c version of SAP.
Any ways i have found one function module which is useful to my requirement as stated below:
DATE_GET_PERIOD
Thanks and Regards,
Sudarshan -
Any BAPI/Function Module for adding new record with dates in PA0027
Hi all,
I am tryig to find is there any BAPI/Function module for updating new record with Start Date and End date for specified Personal Number in PA0027 Table.
In PA0027 table i will be passing start date and end date for selected personal number, it needs to add new record with this details in the table checking the condition that this start date and end dates should not be between any of of start date and end dates for the specified personal number.
thanks for ur time.
MuraliHi Raj/Suresh thanks for ur answers.
but i am having a problem,i gave this values.
INFTY -
0027
NUMBER -
00000010
SUBTYPE -
010
OBJECTID
LOCKINDICATOR
VALIDITYEND -
03/12/2006
VALIDITYBEGIN -
03/01/2006
RECORDNUMBER -
000
RECORD -
P0027
OPERATION -
CHK
TCLAS -
A
DIALOG_MODE -
0
NOCOMMIT -
Y
VIEW_IDENTIFIER
SECONDARY_RECORD
i am getting short dump saying that
The source field is too short.
The current program, "SAPLHRMM", tried to assign a field to a field symbo
However, the field is shorter than the type of the field symbol, which
is not allowed.
The statement in question is in the form ASSIGN f TO <fs> CASTING or
ASSIGN f TO <fs> with a field symbol that was created using the
STRUCTURE addition.
I tried operation - Chage,Create (same thing for all inputs)
is this correct funtion moduel for my requirment?
what ever i am passing the start and end dates this should check in the table records with this personal number and if this start date and end dates are not between of any start and end dates then it should add new record with this dates.
Thanks for ur time.
Murali. -
hello,how can i find the weeks pass the date what i input,if have any functions?
for example,i creat one PO on 2006.8.7,next time,i will judge the PO was pass 4 weeks.Hi,
DATA: weeknum1 LIKE SCAL-WEEK,
weeknum2 LIKE SCAL-WEEK,
week_diff type i.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
date = '20060907'
IMPORTING
WEEK = weeknum1
EXCEPTIONS
DATE_INVALID = 1
OTHERS = 2.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
date = '20060807'
IMPORTING
WEEK = weeknum2
EXCEPTIONS
DATE_INVALID = 1
OTHERS = 2.
week_diff = weeknum1 - weeknum2.
write : 'No of weeks pass ' , week_diff.
Rgds,
Shakuntala
Maybe you are looking for
-
Request.getParameter in jsp
Hi! in my jsp code , i am reading a value from select box and submitting the form to a jsp page. My jsp reads the selected value of the select box and displays some values. This seems working for me as i am using request.getParamater("my_selectbox_na
-
Field in BAPI_GOODSMVT_CREATE
Hi , I am using BAPI_GOODSMVT_CREATE for creating GRN , In transcation MIGO , at line item level there is a field which does not exist in GOODSMVT_ITEM table.Please suggest me how to populate the field which does not exist in BAPI_GOODSMVT_CREATE. Re
-
Anyone know how I can get back to my iTunes Store in Canada? I seem to be in one in the UK.
-
Cannot drag and drop PDF pages in Yosemite Preview App
I suddenly cannot drag and drop PDF pages into the open preview PDF Yosemite> Why? I open a PDF in preview. I used to be able to simply drag a PDF from the desktop (or a JPG) into that open PDF in Preview. Now it won;t let me? Is this a bug or is the
-
Hi, I sold my ipad online. After the buyer collected it, I noticed that the proof of payment that he supplied was fraudulent. I have done a factory reset on the ipad before I gave it to him. Is there some way of getting the product serial number from