How to get the weekends days for a specific date range
I want to select list of only weekend dates from a given date range. Is it possible in SQL?
For example if the range is '08/01/2011' and '08/30/2011'
I want a list
08/06/2011
08/07/2011
08/13/2011
08/14/2011
08/20/2011
08/21/2011
08/27/2011
08/28/2011Thank You, Naveen email:[email protected]
First and easy to do is having a Calendar table, which over there you can have those information.
http://arbibaghdanian.blogspot.com/2011/05/calendar-table.html
Declare @beginDate Date, @EndDate Date
Select @beginDate = '08/01/2011', @EndDate = '08/31/2011'
Declare @Calendar Table
(CalendarDate Date Primary key, IsWeekend Bit, YearNo SmallInt, QuarterNo TinyInt, MonthNo TinyInt, DayOfYearNo SmallInt, DayNo TinyInt, WeekNo TinyInt, WeekDayNo TinyInt)
While @beginDate <= @endDate
Begin
Insert Into @Calendar
Select
@beginDate As CalendarDate
,(Case When DATEPART(Weekday, @beginDate) In (7, 1) Then 1 Else 0 End) As IsWeekend
,DATEPART(Year, @beginDate) As YearNo
,DATEPART(QUARTER, @beginDate) As QuarterNo
,DATEPART(MONTH, @beginDate) As MonthNo
,DATEPART(DayOfYear, @beginDate) As DayOfYearNo
,DATEPART(Day, @beginDate) As DayNo
,DATEPART(Week, @beginDate) As WeekNo
,DATEPART(WEEKDAY, @beginDate) As WeekDayNo
Set @beginDate = DateAdd(Day, 1, @beginDate)
End
Select * From @Calendar Where IsWeekend = 1
Best Wishes, Arbi --- MCC 2011; Please vote if you find this posting was helpful or Mark it as answered.
Similar Messages
-
How to get the week number for a given date?
hi guys,
what is coding to get the week number for a given date?
For example, 1/1/05 is week 1. then 8/1/05 is week 2.The second parameter to pass to the method is supposed to be one of the month constants JANUARY - DECEMBER. It happens to be that their numerical values are 0-11, not 1-12, so your "12" refers to the "13th" month of the year.
givenDate = new GregorianCalendar(2003, Calendar.DECEMBER, 31);
If you want to construct dates and times from strings like you seem to be, look into SimpleDateFormat http://javaalmanac.com/egs/java.text/ParseTime.html
(even still I got WEEK_OF_YEAR as 1 which is true but not really what I expected, excuse my previous reply but I wanted to check the facts before posting this) -
How to get the opening balances for lessthan selected date in cubes.
Hi All,
my task is to get the opening balances for the selected date.
Ex: If I select date say 31-1-2013, I should get the sum of values which are less than the selected date.
in sql:
select sum(balance) from banktrans where banktrans.transdate < 31-1-2013;
BankTable BankTrans
BankId BankId
balance
transdate
BankTable (records):
SCB
BankTrans(records):
a) SCB, 15000, 10-02-2013
b) SCB, 20000, 31-01-2014
c) SCB, 50000, 21-09-2012
If I select date as 31-01-2014, I should get the value as 65000
If I select date as 10-02-2013, I should get the value as 50000
Date will be dynamic selection from years months days hirearchy ( time dimension)
How can i achieve this?
any help is much appreciated.
Thanks,
RakeshDear David,
I've tried the below with static date but i'm not getting the values which are sum of less than the given date.
I've given 1st jan 2013 as static date and I need to get the sum of values which are less than the 1st jan date.
CREATE
MEMBER
CURRENTCUBE.[Measures].[OPENBALANCE]
AS
Sum({Null:[Time].[Years
Quarters Months Weeks Days].[Days].&[2013-01-01T00:00:00]},[Measures].[AmountCur]]),
FORMAT_STRING
= "Standard",
VISIBLE
= 1
can you plz check the above once and guide me.
Thankyou,
Rakesh -
How to get the last day of the week?
Hii
i can get the calender week number for any given date using
SELECT to_char(to_date('04/04/2011','MM/DD/YYYY'),'WW') FROM dual
can any body tell me, how to get the last day of that week ?
and the answer should be 04/08/2011(8th april )
thanks
San
Edited by: sandeep9 on Apr 4, 2011 3:50 AMHi, San,
Here's one way:
WITH sample_data AS
SELECT DATE '2011-04-04' AS dt
FROM dual
SELECT dt
, TO_CHAR (dt, 'WW') AS week_num
, NEXT_DAY ( dt - 1
, TO_CHAR ( TRUNC (dt, 'YEAR') - 1
, 'Day'
) AS end_o_week
FROM sample_data;Another way is to use date arrithmetic:
WITH sample_data AS
SELECT DATE '2011-04-09' AS dt
FROM dual
SELECT dt
, TO_CHAR (dt, 'WW') AS week_num
, TRUNC (dt, 'YEAR')
+ (7 * CEIL ( (dt - (TRUNC (dt, 'YEAR') - 1))
/ 7
- 1 AS using_date_arithmetic
FROM sample_data; -
How to get the last day according to fiscal period input in selection scree
Hello expert
how to get the last day of fiscal period input.
the fiscal period inculdes 1-16
when fiscal period is greater than 12, only calculate the last day of 12nd month
your solution will be apprecaited, FM existing?
thank you
KevinHi,
when you give a particular date in any month
the following fm will give you the last date of that month
here you can give
R_FDATE-HIGH as 01 and month as the period you wnat and year for current year
concatenates '01' month year into r_fdate-high separated by '.'.
then it will give g_ltdt for that month and year which wil be the last date of that month
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = R_FDATE-HIGH
IMPORTING
LAST_DAY_OF_MONTH = G_LTDT
EXCEPTIONS
DAY_IN_NO_DATE = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
thanks & regards,
Venkatesh -
How to get the last day of a month?
HI,
I want to know how to get the last day of a month.
In my JClient form, I tried to get it by using oracle.sql.Date method, that is:
lastday=oracle.sql.Date anydate.lastDayOfMonth();
But it does not work. The result is lastday=anydate.
Why?
StephenYou can use the Calender class...
Calendar c = Calendar.getInstance();
and then something like...
c.add(c.MONTH, 1);
int dayOfMonth = c.get(Calender.MONTH);
c.add(c.DAY_OF_MONTH, - (dayOfMonth-1) );
other usefull functions are:
System.out.println(" YEAR : " + c.get(Calendar.YEAR));
System.out.println(" MONTH : " + c.get(Calendar.MONTH));
System.out.println(" DAY_OF_MONTH : " + c.get(Calendar.DAY_OF_MONTH));
System.out.println(" DAY_OF_WEEK : " + c.get(Calendar.DAY_OF_WEEK));
System.out.println(" DAY_OF_YEAR : " + c.get(Calendar.DAY_OF_YEAR));
System.out.println(" WEEK_OF_YEAR : " + c.get(Calendar.WEEK_OF_YEAR));
System.out.println(" WEEK_OF_MONTH : " + c.get(Calendar.WEEK_OF_MONTH));
System.out.println(" DAY_OF_WEEK_IN_MONTH : " + c.get(Calendar.DAY_OF_WEEK_IN_MONTH));
System.out.println(" HOUR : " + c.get(Calendar.HOUR));
System.out.println(" AM_PM : " + c.get(Calendar.AM_PM));
System.out.println(" HOUR_OF_DAY (24-hour): " + c.get(Calendar.HOUR_OF_DAY));
System.out.println(" MINUTE : " + c.get(Calendar.MINUTE));
System.out.println(" SECOND : " + c.get(Calendar.SECOND));
System.out.println();*/ -
How to get the last error for while loop?
How to get the last error for while loop? I just want transfer the last error for while loop, but the program use the shift register shift all error every cycle.
What do you mean by "get" and "transfer"?
If the shift register is not what you want, use a plan tunnel instead.
Typically, programmers are interested in the first, not last, error.
Can you show us your code so we have a better idea what you are trying to?
LabVIEW Champion . Do more with less code and in less time . -
How to get the first day in the month from a domain date ?
Hi,
I like to know how to get the first day in the month from a domain date?
Thanks
StephenHi Gokul...
Instead of using the funtion module you can just write the 3 statements of code to get the first day of the week.
Its similar to the above one but instead of writing case statement you can achive the following.
data : w_res type i,
w_data type d,
w_res = w_date mod 7.
w_date = w_date - w_res.
write w_date.
This works.
Regards,
Siddarth -
How to get the FIRST DAY OF THE CURRENT MONTH
how to get the FIRST DAY OF THE CURRENT MONTH in oracle 9i.
plzzzzz send immedaily.advance thanksTEST@test SQL> select trunc(sysdate,'MON') from dual;
TRUNC(SYS
01-OCT-06
TEST@test SQL> -
How to get the depreciation areas for an asset in particular period
Hi frndz,
how to get the depreciation areas for an asset in a particular period for writeup or manual depreciation method.
Thanks and regards.
Harisumanth.ChTry table ANLB, then read ANLC.
Regards. -
How to get the version no. for service po?
Hi,
How to get the version no. for service po?For material po we are getting the version from EKKO-REVNO but for service po Ekko-revno is blank.
Regards,
Rachel.Hiee,
It is not like service PO does not have revision.
REVNO will only exists for any document if amendment is made after releasing it. If in EKKO for all service PO revision number is blank then test if version management is active for document type
MM->Purchasing->Version management -> External documents
Here check for your doc type and purchase org version management is active.
Regs,
Appie -
How to get the owner name for the file in ftp using abap ?
Hi folks ,
How to get the owner name for the file in ftp using abap ? please help me very ugernt . I tried with all standard FTP commands
but doest work out me . Helping in this regard highly appreciated ...
Thanks and regards,
Swarupa VanarchiHi
dont you have used the os user while calling the FTP_CONNECT FM?
Hope you are not talking about the user executing the FTP program.
Else If you are talking about the FTP file creator then its not related to abap as you can handle it by maintaining the user in file name itself.
May be i am going too far with if and elses here as your question possesses no clarity.
Plz elaborate your requirement before anybody can help.
Regards
sateesh -
How to get the document number for a ware house order.
Hello gurus,
how to get the document number for a ware house order. [if GI is posted refering that WH order] .. is there any report?
Thanks in advanceThere are several options. When you post a Goods Movement, you can use LB12 -display Transfer Requirement for material document or LB11 Display TR for material.
Depending on how your system is set up you may have gotten a Transfer Order automcatically. In this case you can look at LT24 - Transfer Order for material. -
How to get the baselinegrid position for a line?
Hi All,
How to get the baselinegrid position for a line in a paragraph?Hi,
2nd line baseline grid for yourPara paragraph is:
yourPara.lines[1].baseline;
last line baseline is:
yourPara.endBaseline;
Jarek -
HT204291 how do get the media icon for mac mirroring when running airplay on itunes?
how do get the media icon for mac mirroring when running airplay
Airplay mirroring requires a Mac from 2011 or later, running OSX 10.8 (or later)
http://support.apple.com/kb/HT5404?viewlocale=en_US&locale=en_US
Maybe you are looking for
-
Hi I have old Soundblaster Audigy w-MP3.When I opening the Recorder and try to Play/Save a sound or Track I get this error message(Cannot save into PC Music Library.Please check that Media Database exists in your system). I try everything,But nothing
-
Scanned document but it doesn't show up anywhere...
Everything seems to connect and work but after the scanning is done both computer and scanner (Brother MFC 7820n) just sit there...nothing loaded Preview or anywhere else. Any suggestions???
-
Getting error while using isIntialized
Hi i wrote the code like this.B init{ if(not isIntialized(fahrenheit)){ fahrenheit=celcius * 9 / 5 + 32 i'm getting the error like this.Any one plz help me to solve this, executing commandline: [C:\Externals\java\NetBeans\javafx2\javafx-sdk1.0\bin\..
-
Handling HTML-reserved characters in passed item values
I've got a pair of pages in an application where one gets an item value from an inline value of a report on the other page. Since the link I created is conditional, I used the concatenate html string method to create the link. However, some of the va
-
Comcast, Mail, and Thunderbird
I just installed my software, and I cannot figure out how to use mail. I have a comcast account, and I am not sure which option to pick in the menu (I have been doing 'other'). I searched on comcast's website for help but there was nothing. How do I