Date Difference Function

Erne ernestogiannotta at tiscalinet.it
Mon Jul 4 12:00:17 CDT 2005


Hello Ivan,

thanks for listening

On 03-lug-05, at 21:48, Ivan Smahin wrote:

> Hello Erne,
>
>
> Erne wrote:
>
>> Hello list,
>> I have a task but can't figure out how to accomplish it easily,
>> maybe somebody has idea
>> I need to know how many days separate a recurrence (stored as   
>> DateField) from today
>> e.g.
>> DateFormat is kMDY
>> Separatore is /
>> the recurrence is 01/03/1958
>> and today is 12/03/2005
>>
>
> I've read you message number times but I'm afraid I did not get it  
> completelly.
>
> Probably it would be better to see a couple of real examples?
>
> 01/03/1958    12/03/2005     -    11 days
>
> Right?
>

nope! that's kMDY (the default setting of Valentina)
so it is 31 days but you must take into account the fact
that next recurrence will occur on next year, you see?

to obtain this I must compare 01/03/2006 against 12/03/2005

otherwise (comparing 01/03/2005 against 12/03/2005) the difference  
will be -334

> Anycase it seems you should consider usage of such set of SQL- 
> functions:
> Year
> Month
> Day
>
> Just for simplifying your scripts (instead of continiously DatePart  
> usage).
>

yep! that's a part of what I was looking for... (so what's the use of  
DatePart function ?)

I must build a new date to compare against today
based on the month and day of the stored date
but change the year with:
- the current year if recurrence is after today (i.e. is yet to come  
this year)
- the next year if recurrence is before today (i.e. is already gone  
this year)

so I didn't find a better way to build this comparison date
than pass a date string to the method that will be coerced into a  
date type by the parser

trouble is that if Date format used in DB should change (say from MDY  
to DMY)
I must update the Method formula
is there a way to build a date that not depends on format things like
Separator (db.DateSep) and dateparts order?


Cool Runnings,
Erne.

/ |\ |\  | /
– |/ | \ | –
\ |\ |  \| \



More information about the Valentina mailing list