473,834 Members | 1,682 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculation of seconds for a month

Dear all,

Do any one have idea how to obtain the exactly number of seconds in a month
with given month and year using DB2 given functions?
The formula is as simple as "No_of_days_for _a_month" * 60 * 60 * 24 .. but
It is a headache for me to find the No_of_days_for_ a_month... in DB2

Thanks very much!

Henry
Nov 12 '05 #1
3 9252

"kaming" <gu***@guest.co m> wrote in message
news:ck******** *@imsp212.netvi gator.com...
Dear all,

Do any one have idea how to obtain the exactly number of seconds in a month with given month and year using DB2 given functions?
The formula is as simple as "No_of_days_for _a_month" * 60 * 60 * 24 .. but
It is a headache for me to find the No_of_days_for_ a_month... in DB2

Thanks very much!

Look at the days() function in the SQL Reference for your platform.

The days() function expects a single date argument and returns the number of
days between Jan 1, 0001 and the date in the argument. While that is not
particularly interesting with respect to a single date, it gets a lot more
useful if you calculate the days() result on two dates and then subtract one
from the other: that tells you the number of days difference between the
two.

Therefore:

select days('2004-02-01') - days('2004-01-01')
from sysibm.sysdummy 1

returns 31, the number of days in January, 2004.

By the same token:

select days('2004-03-01') -days('2004-02-01') as feb_2004,
days('2003-03-01') - days('2003-02-01') as feb_2003
from sysibm.sysdummy 1;

returns:

FEB_2004 FEB_2003
29 28

In other words, Feb 2004 (which is a leap year) has 29 days while Feb 2003
(which is not a leap year) had 28 days.

Rhino
Nov 12 '05 #2
kaming wrote:
Dear all,

Do any one have idea how to obtain the exactly number of seconds in a
month with given month and year using DB2 given functions?
The formula is as simple as "No_of_days_for _a_month" * 60 * 60 * 24 .. but
It is a headache for me to find the No_of_days_for_ a_month... in DB2


How about simply taking the "day" of the last day of a month?

VALUES DAY(DATE('2004-04-01') - 1 DAY)

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #3
"kaming" <gu***@guest.co m> wrote in message news:<ck******* **@imsp212.netv igator.com>...
Dear all,

Do any one have idea how to obtain the exactly number of seconds in a month
with given month and year using DB2 given functions?
The formula is as simple as "No_of_days_for _a_month" * 60 * 60 * 24 .. but
It is a headache for me to find the No_of_days_for_ a_month... in DB2

Thanks very much!

Henry

hello Henry,

While the others have given you good advice, if you want a really
accurate count in seconds, you must also consider leap seconds of
which there have been about 22 since about 1970. The national
observatories keep a record of them and they are identifiable in time
signals, though I am not familiar with the technical facilities
involved to obtain them.

Robert
Nov 12 '05 #4

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

Similar topics

2
2535
by: Terry | last post by:
I have used the code provided in the PreciseDateDiff function at the following Access Web link to calculate the time change date (from Daylight to Standard time and vice versa): http://www.mvps.org/access/api/api0024.htm But looks like for this week only, there is a small error in the calculation in the 'GetSundate' function included in the code. You can see what I mean by adding the code below (copied directly from the above link)...
6
1991
by: SharkSYA | last post by:
Hi, Hoping someone can help. I've designed a running database Access 2003 but am having trouble with the pace calculation. I've googled and searched the usual suspects but it doesn't give the answer or it gives me the same answer as below.
2
1413
by: Issac Gomez | last post by:
IN VB.Net, you can use the DateDiff method to calculate the difference between 2 days. How do you do this in C#? I want to find the number of days between 2 dates. I there a 0 days, then I want to know the number of hours and minutes between 2 dates I see there is a method for the DateTime object which allows me to subtract, but it requires a TimeSpan object, andI am not quite shure how to create this correctly. I presume it goes something...
11
7993
by: Bdog | last post by:
I'm trying to find out if now() is between 9:00 AM and 5:00 PM I've tried a few things but can't get it to work. Thanks
6
5305
by: jimfortune | last post by:
In: http://groups.google.com/group/comp.databases.ms-access/msg/60d7faa790c65db1 james.ea...@gmail.com said: :Ok, I've answered the first half of my own question. From a MSDN :article, I can now use the following to reference the last primary :key's values: :
2
6789
by: smcgrath via AccessMonster.com | last post by:
I have a table listing accounts with a closed date - our Trial balance drops the account after 7 days but our database keeps the record forever - How do I calculate the end of month less 7 days so that I can get an actual count of the accounts that were closed during the month. I believe that the calculation involves Between(DateSerial(year(Date() etc but I can't figure it out. Thanks, -- Message posted via http://www.accessmonster.com
13
14936
by: Stephenoja | last post by:
Hello guys, Thanks for all the help with the last question. I have another one. Does anyone know how to let access automatically calculate age and display in field when the person's date of birth is entered? Is that even possible? Any help would be greatly appreciated. Thanks.
5
6263
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a user modifies any of the x, y and z values.
19
2740
by: edfialk | last post by:
Hi, does anyone happen to know of a script that would return the number of seconds in a month if I give it a month and a year? My python is a little weak, but if anyone could offer some suggestions I think I could handle it myself, or if anyone happens to know of a script already written that performs this I would be extremely grateful. Thanks! -Ed
0
9796
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10789
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10504
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
10544
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
10214
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...
1
7755
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
5624
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.