Hi,
I have a need to create a syntax , so that basing on the current_date, the sql generated will always give me the Last day of the Last Quarter.
I am new to SQL, so need help
thanks.
Ed
9 14500 Rabbit 12,516
Recognized Expert Moderator MVP
Define quarter. Calendar quarter? Fiscal Quarter? If fiscal, what is the start and end? It varies.
But the basic algorithm is this: - if (month of some date) <= (month of last date in fiscal year) then
-
use current year
-
else
-
use next year
-
end if
We need the calendar quarter. So if I run the SQL now, it should give me sep 30 2012. and if I run it in Jan 2013, then it should give me 31 Dec 2012.
Rabbit 12,516
Recognized Expert Moderator MVP
Use the date_trunc() function to get the first day of the quarter and then subtract one day.
the date_trunc() function does not work in Postgres. Can u send me the correct SQL for last day of Quarter.
yes, it does, i apprecaite. I am getting first day of curretn quarter, still looking for how to minus one day: select date_trunc('qua rter',current_d ate)
Once again I apprecaite the help this forum is providing.
Rabbit 12,516
Recognized Expert Moderator MVP
In that same link, it also shows you how to subtract a time interval.
Yes, Thanks Rabbit, it works.. select date(date_trunc ('quarter',curr ent_date))-integer '1' Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Neeper |
last post by:
Hi,
I've got a transactions table with a tstamp field (datetime type) and
I need help creating a SELECT query to retrieve only last transactions
that occured within the last 5 minutes. The datetime type writes the
tstamp as YYYY-MM-DD HH-MM-SS and I am using mySQL 4.1.
Please help.
|
by: Matt |
last post by:
Hello,
I have a query that I would like to schedule in DTS. The criteria of
this query checks for records in the table that are within the current
quarter. Here is what I have.
WHERE submit_date BETWEEN '01/01/2005' AND '03/31/2005'
I would like to dynamically generate the Quarter End and Quarter
Beginning dates within my where clause based on the date that DTWS
|
by: priscilla.jenkins |
last post by:
Alright, I'm really new to SQL and VBA and all this, so I might be
completely off course...but just tell me. I know C and Assembly, but
that doesn't help me much here.
I'm trying to create a module that creates 5 queries (that a report is
based on) based on a table that the user defines. My tables are named
by date (not my choice), for example:
-ArchivedActions05-20-05 Everything involving that seems fine.
I'm getting a syntax error...
|
by: ben |
last post by:
getting a bit confused with the details of how c's grammar is
specified, especially when you get self-reference like in this:
postfix-expression:
primary-expression
postfix-expression
postfix-expression ( argument-expression-listopt )
postfix-expression . identifier
postfix-expression -> identifier
postfix-expression ++
|
by: Hemanth |
last post by:
Hello,
How do I find the first and last non-numeric char positions (using
regexp) in an alphanumeric string?
For example,
99ABC1A => should return 2, 6
DE8A1 => should return 0, 3
Thanks,
| |
by: schapopa |
last post by:
Hi,
I want to create query where I could group records by quarters, and get
the last record in each group.
e.g
Create Table MyTable
(
Value ,
date
)
|
by: Florian Lindner |
last post by:
Hello,
can I determine somehow if the iteration on a list of values is the last
iteration?
Example:
for i in :
if last_iteration:
print i*i
else:
|
by: benchpolo |
last post by:
First Day of the QUARTER
select DATEADD(qq, DATEDIFF(qq,0,getdate()), 0)
Question: How do I get the last DAY of the QUARTER?
For example: 1st Quarter is 01/01/2008 to 03/31/2008.
I am having difficulties finding the last day of the quarter.
|
by: gimme_this_gimme_that |
last post by:
Is there a way to get the last day of the previous business quarter
from DB2?
For 10/21/2008 the day would be 9/30/2008.
Thanks.
|
by: grinder332518 |
last post by:
Hi
I am running a “last” command and saving the output to a file, which I am going to
ftp to my PC for loading into a DB table.
last > last.txt
I am finding that I am getting lots of duplicate entries for most logins in last.txt.
Eg
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |