Search the web
Sign In
New User? Sign Up
s-base · S-Base Users Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Query problem   Message List  
Reply | Forward Message #628 of 1020 |
Re: Query problem

In article <a5a4659c4c.B21306@...>,
<B21306@...> wrote:
> --------------------------
> def proc age_show

> if r_froster_card.g_date <1
> r_froster_card.g_age = 0

> else

> r_froster_card.g_age = (@date-r_froster_card.g_date)
> endif

> if @date < r_froster_card.g_date
> r_froster_card.g_age = 0
> endif

> return r_froster_card.g_age

> enddef

> ------------------------------------------------
> I will look for a another solution again.
> Thank You very much for Your help Wim !!

It looks to me Hans, that with your formula of

(@date - r_froster_card.g_date)

you are trying to subtract one date from another date. The answer does not
(usually) make sense, because S-Base will format the result as a date
also, based on a starting date of 24th November -4713. For example, if I
try to subtract the first of January this year from today's date I get

print (@date - @timefoy(@date))
02/03/-4712

instead of 99, which is the number of days between the two dates.

If you use @int(@date - r_froster_card.g_date) instead, you will force the
^^^^
result to be an integer, which you can then manipulate as you wish.

I have never been able to get the data-type sub-type (time/date interval)
to make any sense. On the occasions when I've needed to display a time
interval, I have usually found it best to extract the difference in days
(as above), then convert that into a string such as "00y 04m 09d" or
however you want it using my own function depending on what I want.

I have attached a couple of functions to this email for you to try out.
They are attached rather than included within the body as some of the
lines are a bit long, and may get formatted into multiple lines by your
email reader. Both the functions can be made much shorter once you
understand how they work.


> A Happy Easter for All say

> Hans-Juergen Barthelmehs

A Happy Easter to you too.

Regards,

--
Robin Hampshire
robin@...


Fri Apr 9, 2004 12:24 pm

robinsbase
Offline Offline
Send Email Send Email


| this function assumes that all calendar months are of thirty days
| and that there are no leap years. It is rather crude and inaccurate
| over long time intervals.
| returns a string representation of a number of days converted to
| years, months and days
def proc time_interval(diff_days)
local int_str = ""
local years = diff_days // 365 , residue = diff_days % 365
local months = residue // 30, days = residue % 30
if years then int_str = @str(years) + "Y "
if months then int_str += @str(months) + "M "
return int_str + @str(days) + "D"
enddef

| this function will find the number of years, months and days between
| two dates, regardless of which date is the earlier.
| "inclusive" should be TRUE or FALSE depending on whether the difference
| should be inclusive or not (i.e. do both dates "count" towards the total).
| returns a string representing "xxY xxM xxD"
def proc time_interval_exact(date_1, date_2, inclusive)
local int_str = ""
local d_low = @min(date_1,date_2)
local d_hi = @max(date_1,date_2)
local d_1 = @timedom(d_low), m_1 = @timemoy(d_low) + 1, y_1 = @timey(d_low)
local d_2 = @timedom(d_hi), m_2 = @timemoy(d_hi) + 1, y_2 = @timey(d_hi)
local years_diff = y_2 - y_1
| if the higher date is earlier in a subsequent year reduce years_diff by 1
if @datesn(@str(d_2)+"."+@str(m_2)+"."+@str(y_1)) < d_low then years_diff-=1
local months_diff = (m_2 - m_1 + 12) % 12
| if the day of month for later date is higher than for earlier date,
| then the difference of days is a simple subtraction, but
| if the day of month for later date is lower than for earlier date,
| reduce the months_diff by 1, and find the number of days from the earlier
| date to end of that earlier month.
local days_diff = 0
if d_2 >= d_1
days_diff = d_2 - d_1 + inclusive
else
months_diff -= 1
local days_to_end_month = 0
if m_1 = 12 {December, must be 31 days}
days_to_end_of_month = 31 - d_1
else
days_to_end_of_month = @int(@datesn("1."+@str(m_1+1)+"."+@str(y_1)) -
d_low) - 1
endif
days_diff = d_2 + days_to_end_of_month + inclusive
endif
if years_diff then int_str = @str(years_diff) + "Y "
if months_diff then int_str += @str(months_diff) + "M "
return int_str + @str(days_diff) + "D"
enddef


Forward
Message #628 of 1020 |
Expand Messages Author Sort by Date

Hello All, In one problem I can not found a solution. The problem is.... In a Query window createt with SAM I can found a Date Value eg. 05/04/2004 that is all...
B21306@...
Send Email
Apr 5, 2004
11:47 am

... Nah,... wenig zu tun hier nicht? Hallo Hans-Juergen, Habe mal gewartet ob einer etwas antworten wollte, scheint nicht so zu sein :-( Aber auf English: I've...
Wim Ekels
wimekels
Offline Send Email
Apr 6, 2004
11:42 am

... Hmmm... Yes I have see this but I think this is not the main problem. SBase SAM use in the Query the data typ from File without subtype or ? Ok I can use...
B21306@...
Send Email
Apr 8, 2004
5:42 pm

In article <a5a4659c4c.B21306@...>, ... It looks to me Hans, that with your formula of (@date - r_froster_card.g_date) you are trying to subtract one...
Robin Hampshire
robinsbase
Offline Send Email
Apr 9, 2004
12:32 pm

In message <Sc9cec05d0robin@...> you wrote: snip Hi Robin, Thanks for your email - I,m sorry for the delay with my reply. Your proc in the attachmend...
B21306@...
Send Email
Apr 14, 2004
4:20 pm

In article <49bf949f4c.B21306@...>, ... OK. I think I was misunderstanding the problem. If I understand correctly (at last), you have a record with a...
Robin Hampshire
robinsbase
Offline Send Email
Apr 15, 2004
11:34 am

In message <4c9ff6eac1robin@...> you wrote: Hello, ... Or my Question was not the best...... :-) ... Yes True. ... So it is. A Example is search for...
B21306@...
Send Email
Apr 15, 2004
7:48 pm

Hello Robin and Hans-Juergen ... [total snip] I followed your discussion and believe it might be the best for Robin to see the app you made. I've received from...
Wim Ekels
wimekels
Offline Send Email
Apr 16, 2004
8:38 am

Hi all, Someone (IP address 62.254.0.30) fetched the sample... In the meantime Hans-Jürgen has send me the newest version! Please follow the same link once...
Wim Ekels
wimekels
Offline Send Email
Apr 16, 2004
12:08 pm

In article <Marcel-1.53-0416120836-0b0tRkF@...>, ... Thanks Wim, I'll have a look. In the meantime, I have cobbled together something that Hans-Jurgen can...
Robin Hampshire
robinsbase
Offline Send Email
Apr 16, 2004
12:28 pm

In article <4ca086ecd3robin@...>, ... I've had a look at your app Hans-Jurgen, and I've managed to get the query working properly. What I've done is...
Robin Hampshire
robinsbase
Offline Send Email
Apr 16, 2004
3:36 pm

In message <Sca0981f1crobin@...> you wrote: Hello Robin, ... You have done big work with all Your proc and I think its a way become the Query for age...
B21306@...
Send Email
Apr 19, 2004
9:16 pm

In article <46622ca24c.B21306@...>, ... Don't mention it Hans-Jurgen, I am glad to be of help. ... I have your application here, which I downloaded...
Robin Hampshire
robinsbase
Offline Send Email
Apr 20, 2004
8:48 am

In message <4ca28216b9robin@...> you wrote: Hello Robin, with many snip... ... That can I understand. Now I have found, I think this is this rtn_str...
B21306@...
Send Email
Apr 20, 2004
12:24 pm

In article <d60796a24c.B21306@...>, ... Sent via email -- Robin Hampshire robin@......
Robin Hampshire
robinsbase
Offline Send Email
Apr 21, 2004
7:56 am

In article <48a52ba04c.B21306@...>, ... OK. I've been having a little think about this and I believe it will be possible, though a bit tricky. First of...
Robin Hampshire
robinsbase
Offline Send Email
Apr 16, 2004
12:17 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help