How do you test to see if it's a leap year? The first thing that comes
to my mind is checking to see if DATE(nCurrentYearVariable,2,29) throws
an error or not. e.g.
dDate = DATE(nCurrentYearVariable,2,29)
lLeapYear = not empty(dDate)
Better ideas?
--
Mike Babcock, MCP
MB Software Solutions, LLC
President, Chief Software Architect
http://mbsoftwaresolutions.com
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/4DA4C8B2.1040504@mbsoftwaresolutions.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Something like this?
dDate = ctod('2/28/'+<year as a string>) + 1
if month(dDate) = 2
' leap year
Else
' not leap year
Endif
Lou
-----Original Message-----
From: profoxtech-bounces@leafe.com [mailto:profoxtech-bounces@leafe.com] On
Behalf Of MB Software Solutions, LLC
Sent: Tuesday, April 12, 2011 2:49 PM
To: profoxtech@leafe.com
Subject: Testing for leap year?
How do you test to see if it's a leap year? The first thing that comes
to my mind is checking to see if DATE(nCurrentYearVariable,2,29) throws
an error or not. e.g.
dDate = DATE(nCurrentYearVariable,2,29)
lLeapYear = not empty(dDate)
Better ideas?
--
Mike Babcock, MCP
MB Software Solutions, LLC
President, Chief Software Architect
http://mbsoftwaresolutions.com
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/006701cbf95b$8c4edd70$a4ec9850$@com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
mdate=CTOD("15/2/2011")
ldate=Gomonth(mdate - Day(mdate) + 1, 1) - 1
it will return either 28 or 29
On Wed, Apr 13, 2011 at 9:48 AM, MB Software Solutions, LLC <
mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:
> How do you test to see if it's a leap year? The first thing that comes
> to my mind is checking to see if DATE(nCurrentYearVariable,2,29) throws
> an error or not. e.g.
>
> dDate = DATE(nCurrentYearVariable,2,29)
> lLeapYear = not empty(dDate)
>
> Better ideas?
>
> --
> Mike Babcock, MCP
> MB Software Solutions, LLC
> President, Chief Software Architect
> http://mbsoftwaresolutions.com
> http://twitter.com/mbabcock16
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/BANLkTik3XH2Q=m+Rp9Z3J2-djmTeo=B5hQ@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
On 4/12/11 2:49 PM, Lou Syracuse wrote:
> Something like this?
>
> dDate = ctod('2/28/'+<year as a string>) + 1
> if month(dDate) = 2
> ' leap year
> Else
> ' not leap year
> Endif
It isn't as simple as that. Here's the pseudocode algorithm from wikipedia:
if year modulo 400 is 0
then is_leap_year
else if year modulo 100 is 0
then not_leap_year
else if year modulo 4 is 0
then is_leap_year
else
not_leap_year
But I like Mike's TRY/CATCH approach.
Paul
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/4DA4CA03.9000806@ulmcnett.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
On 4/12/2011 5:53 PM, Sytze de Boer wrote:
> mdate=CTOD("15/2/2011")
> ldate=Gomonth(mdate - Day(mdate) + 1, 1) - 1
I don't think you meant 15 in your expression above, did you? IAC,
thanks guys, but out of those 2, I like mine better. :-)
--
Mike Babcock, MCP
MB Software Solutions, LLC
President, Chief Software Architect
http://mbsoftwaresolutions.com
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/4DA4CA42.6000909@mbsoftwaresolutions.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
On Apr 12, 2011, at 5:54 PM, Paul McNett wrote:
> But I like Mike's TRY/CATCH approach.
In Python you could do that, or simply:
import calendar
return calendar.isleap(year)
-- Ed Leafe
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/F1ADC012-43E4-487E-AF41-03FFF334751F@leafe.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
On 4/12/11 2:54 PM, Paul McNett wrote:
> On 4/12/11 2:49 PM, Lou Syracuse wrote:
>> > Something like this?
>> >
>> > dDate = ctod('2/28/'+<year as a string>) + 1
>> > if month(dDate) = 2
>> > ' leap year
>> > Else
>> > ' not leap year
>> > Endif
> It isn't as simple as that.
Sorry Lou, I misread your approach on first glance - like the others, this one should
work too as long as VFP's leap year algorithm is correct, which it seems to be.
Paul
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/4DA4CAA2.3080301@ulmcnett.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Whats wrong with the 15?
It could be any number in a month (but short of 28)
S
On Wed, Apr 13, 2011 at 9:55 AM, MB Software Solutions, LLC <
mbsoftwaresolutions@mbsoftwaresolutions.com> wrote:
> On 4/12/2011 5:53 PM, Sytze de Boer wrote:
> > mdate=CTOD("15/2/2011")
> > ldate=Gomonth(mdate - Day(mdate) + 1, 1) - 1
>
>
> I don't think you meant 15 in your expression above, did you? IAC,
> thanks guys, but out of those 2, I like mine better. :-)
>
> --
> Mike Babcock, MCP
> MB Software Solutions, LLC
> President, Chief Software Architect
> http://mbsoftwaresolutions.com
> http://twitter.com/mbabcock16
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/BANLkTi=ixzWPGg2jhTYMRhvSMcPy9O2Ccw@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
On Apr 12, 2011, at 5:57 PM, Sytze de Boer wrote:
> Whats wrong with the 15?
> It could be any number in a month (but short of 28)
It's inefficient, as it requires an extra call to DAY(mdate). A cleaner approach would be to select the day as 1, and subtract one day.
-- Ed Leafe
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/801CD752-8E6B-4EFF-BACD-8EA24FB18864@leafe.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
On 4/12/11 2:56 PM, Ed Leafe wrote:
> On Apr 12, 2011, at 5:54 PM, Paul McNett wrote:
>
>> > But I like Mike's TRY/CATCH approach.
>
> In Python you could do that, or simply:
>
> import calendar
> return calendar.isleap(year)
Ok so Mike you have the option of shelling out to a Python interpreter and running
the above code. ;)
Paul
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/4DA4CB37.8060003@ulmcnett.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.