467,198 Members | 1,301 Online

# 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
• viewed: 9073
Share:
3 Replies
 "kaming" wrote in message news:ck*********@imsp212.netvigator.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.sysdummy1 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.sysdummy1; 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" wrote in message news:... 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 discussion thread is closed

Replies have been disabled for this discussion.