473,651 Members | 2,645 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding first saturday of month

Select trunc(sysdate,' MM')
from dual
of course gives me the first day of the month, may I ask what the
query is to find the first saturday of the month?
Jul 19 '05 #1
11 22457
"Solomon Grundy" <lo********@net scape.net> wrote in message
news:6a******** *************** ***@posting.goo gle.com...
| Select trunc(sysdate,' MM')
| from dual
| of course gives me the first day of the month, may I ask what the
| query is to find the first saturday of the month?

check out the NEXT_DAY function

;-{ mcs
Jul 19 '05 #2
Mark C. Stock wrote:
"Solomon Grundy" <lo********@net scape.net> wrote in message
news:6a******** *************** ***@posting.goo gle.com...
| Select trunc(sysdate,' MM')
| from dual
| of course gives me the first day of the month, may I ask what the
| query is to find the first saturday of the month?

check out the NEXT_DAY function

;-{ mcs


And be careful with trunc(sysdate):
SQL> select trunc(sysdate,' MM') from dual;

TRUNC(SYSDATE,'
---------------
01-FEB-04

--

Regards,
Frank van Bortel

Jul 19 '05 #3

"Frank van Bortel" <fv********@net scape.net> wrote in message
news:c1******** **@news4.tilbu1 .nb.home.nl...
| Mark C. Stock wrote:
| > "Solomon Grundy" <lo********@net scape.net> wrote in message
| > news:6a******** *************** ***@posting.goo gle.com...
| > | Select trunc(sysdate,' MM')
| > | from dual
| > | of course gives me the first day of the month, may I ask what the
| > | query is to find the first saturday of the month?
| >
| > check out the NEXT_DAY function
| >
| > ;-{ mcs
| >
| >
|
| And be careful with trunc(sysdate):
| SQL> select trunc(sysdate,' MM') from dual;
|
| TRUNC(SYSDATE,'
| ---------------
| 01-FEB-04
|
| --
|
| Regards,
| Frank van Bortel
|

frank,

the OP was intending to use trunc(sysdate,' MM'), which reliably returns the
first day of the current month -- in what way are you suggesting to be
careful with trunc(sysdate)?

;-{ mcs
Jul 19 '05 #4
Mark C. Stock wrote:
"Frank van Bortel" <fv********@net scape.net> wrote in message
news:c1******** **@news4.tilbu1 .nb.home.nl...
| Mark C. Stock wrote:
| > "Solomon Grundy" <lo********@net scape.net> wrote in message
| > news:6a******** *************** ***@posting.goo gle.com...
| > | Select trunc(sysdate,' MM')
| > | from dual
| > | of course gives me the first day of the month, may I ask what the
| > | query is to find the first saturday of the month?
| >
| > check out the NEXT_DAY function
| >
| > ;-{ mcs
| >
| >
|
| And be careful with trunc(sysdate):
| SQL> select trunc(sysdate,' MM') from dual;
|
| TRUNC(SYSDATE,'
| ---------------
| 01-FEB-04
|
| --
|
| Regards,
| Frank van Bortel
|

frank,

the OP was intending to use trunc(sysdate,' MM'), which reliably returns the
first day of the current month -- in what way are you suggesting to be
careful with trunc(sysdate)?

;-{ mcs


Well, for one, I got my wires crossed.
Apologies, forget about previous posting of mine.
OP is correct
--

Regards,
Frank van Bortel

Jul 19 '05 #5


"Solomon Grundy" <lo********@net scape.net> wrote in message
news:6a******** *************** ***@posting.goo gle.com...
Select trunc(sysdate,' MM')
from dual
of course gives me the first day of the month, may I ask what the
query is to find the first saturday of the month?


This appears to work for me:

trunc(to_date(y ear||month),'D' )+6 from dual

zin
--- http://www.zintel.com
Jul 19 '05 #6

"George Ziniewicz" <zi**@cox.net > wrote in message
news:ZoQ0c.5727 $506.3314@fed1r ead05...
|
|
| "Solomon Grundy" <lo********@net scape.net> wrote in message
| news:6a******** *************** ***@posting.goo gle.com...
| > Select trunc(sysdate,' MM')
| > from dual
| > of course gives me the first day of the month, may I ask what the
| > query is to find the first saturday of the month?
|
| This appears to work for me:
|
| trunc(to_date(y ear||month),'D' )+6 from dual
|
| zin
| --- http://www.zintel.com
|
|

zin,

you might want to try again (seriously, no sarcasm intended)

this expression (even with the added SELECT) doesn't run, and if it did,
adding 6 days to a date value only returns a saturday if the date is known
to be a sunday -- so to use something like this to find the first saturday
of the month, you'd have to first find the last sunday of the prior month

did you have something else in mind when you posted this?

;-{ mcs
Jul 19 '05 #7

"Mark C. Stock" <mcstockX@Xenqu ery .com> wrote in message
news:To******** ************@co mcast.com...
|
| "George Ziniewicz" <zi**@cox.net > wrote in message
| news:ZoQ0c.5727 $506.3314@fed1r ead05...
| |
| |
| | "Solomon Grundy" <lo********@net scape.net> wrote in message
| | news:6a******** *************** ***@posting.goo gle.com...
| | > Select trunc(sysdate,' MM')
| | > from dual
| | > of course gives me the first day of the month, may I ask what the
| | > query is to find the first saturday of the month?
| |
| | This appears to work for me:
| |
| | trunc(to_date(y ear||month),'D' )+6 from dual
| |
| | zin
| | --- http://www.zintel.com
| |
| |
|
| zin,
|
| you might want to try again (seriously, no sarcasm intended)
|
| this expression (even with the added SELECT) doesn't run, and if it did,
| adding 6 days to a date value only returns a saturday if the date is known
| to be a sunday -- so to use something like this to find the first saturday
| of the month, you'd have to first find the last sunday of the prior month
|
| did you have something else in mind when you posted this?
|
| ;-{ mcs
|
|

woops -- my bad

spent a week working on MS-Access recently, so i mis-read the "D" format

however, 'D' truncation to the first day of the week does not always return
sunday -- it is dependent on the NLS_TERRITORY setting (then again, to a
degree, so was my solution using the NEXT_DAY function)

;-{ mcs
Jul 19 '05 #8
"Mark C. Stock" <mcstockX@Xenqu ery .com> wrote in message news:<M6******* *************@c omcast.com>...
"Mark C. Stock" <mcstockX@Xenqu ery .com> wrote in message
news:To******** ************@co mcast.com...
|
| "George Ziniewicz" <zi**@cox.net > wrote in message
| news:ZoQ0c.5727 $506.3314@fed1r ead05...
| |
| |
| | "Solomon Grundy" <lo********@net scape.net> wrote in message
| | news:6a******** *************** ***@posting.goo gle.com...
| | > Select trunc(sysdate,' MM')
| | > from dual
| | > of course gives me the first day of the month, may I ask what the
| | > query is to find the first saturday of the month?
| |
| | This appears to work for me:
| |
| | trunc(to_date(y ear||month),'D' )+6 from dual
| |
| | zin
| | --- http://www.zintel.com
| |
| |
|
| zin,
|
| you might want to try again (seriously, no sarcasm intended)
|
| this expression (even with the added SELECT) doesn't run, and if it did,
| adding 6 days to a date value only returns a saturday if the date is known
| to be a sunday -- so to use something like this to find the first saturday
| of the month, you'd have to first find the last sunday of the prior month
|
| did you have something else in mind when you posted this?
|
| ;-{ mcs
|
|

woops -- my bad

spent a week working on MS-Access recently, so i mis-read the "D" format

however, 'D' truncation to the first day of the week does not always return
sunday -- it is dependent on the NLS_TERRITORY setting (then again, to a
degree, so was my solution using the NEXT_DAY function)

;-{ mcs


I believe the SQL posted earlier may have a problem if the first day
of the month is a Saturday as my test found the next Saturday in this
case. (May is the only month in 2004 that starts on a Saturday)

Here is my attempt:
1 select next_day(last_d ay(add_months(s ysdate,-1)),'Saturday')
2* from dual
@UT1 SQL>> /

NEXT_DAY(
---------
06-MAR-04

1 row selected.

If you substitute any date in May for sysdate it still produces
Saturday 1-May as the result.

HTH -- Mark D Powell --
Jul 19 '05 #9
lo********@nets cape.net (Solomon Grundy) wrote in message news:<6a******* *************** ****@posting.go ogle.com>...
Select trunc(sysdate,' MM')
from dual
of course gives me the first day of the month, may I ask what the
query is to find the first saturday of the month?

Try this
select trunc(sysdate,' mm')+(7- to_char(trunc(s ysdate,'mm'),'d ')) first_sat
from dual;

Replace sysdate with any date.
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6782
by: N8tor | last post by:
I'm a programming neophyte so needless to say I need some help on some VB scripting. I need to create some code to find what month it will be this coming Saturday. I also need to do the same for the week # of the month this Saturday. And finally, the Year of the month this Saturday. Could someone help me with this?
20
11835
by: Gav | last post by:
I have a database with date of births stored dd/mm/yyyy (english dating system) and =date() returns a date in the same format in my server. how do i find the persons age using these two pieces of date. thanks gavin
5
10820
by: Parintas Themis STE Kardias | last post by:
Hi How can i have in a textbox the first sunday of a month
2
2341
by: planetthoughtful | last post by:
Hi All, I'm building some reports in Acc97 and using a custom calendar form to allow users to pick dates with which to report. I'm wondering if there's an easy way in code to be able to automatically work out the end-of-week date and end-of-month date from an arbitrary date value? To explain a little further. Let's say a user wants to view a weekly
3
5872
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 and I was wondering if anyone knows of a function or quick way, given a scalar representation of month (as a number between 1 and 12), day, and year (as a four digit number, e.g. 2007), how would I tell if that day is a Saturday? Thanks, - Dave
3
2898
by: foxykitty | last post by:
Hi, How can I group in my qryMonthlyHours in SQL view by , and then sum done in that month? I have another query - qrySaturdayRota ,,,,, ALL THIS IS GROUPED EXCEPT FOR has a criteria = Like "Saturday Rota" Or Like "Sat Rota" Or Like "Rota"
10
2380
by: kyosohma | last post by:
Hi, I am working on a timesheet application in which I need to to find the first pay period in a month that is entirely contained in that month to calculate vacation time. Below are some example date ranges: December 31, 2006 January 13, 2007 # doesn't earn January 14, 2007 January 27, 2007 # does earn January 28, 2007 February 10, 2007 # doesn't
11
220
by: Solomon Grundy | last post by:
Select trunc(sysdate,'MM') from dual of course gives me the first day of the month, may I ask what the query is to find the first saturday of the month?
8
3960
code green
by: code green | last post by:
I need to generate the date for the latest Friday and the Saturday previous to this ie 7 days. I am generating reports for the periods Yesterday, Month to date and Sat-Fri so I create the dates in PHP and pass them to a function to be used in the BETWEEN phrase of a query. This could run almost any day of the week but most probably the Friday itself. I have figured it out for yesterday $start = date('Y-m-d',strtotime('-1 day')); $finish...
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8695
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8460
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8576
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7296
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6157
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4281
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1906
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.