Datediff differences in US and Europe

Ivan Smahin ivan_smahin at paradigmasoft.com
Thu Jun 28 04:16:51 CDT 2012


On Jun 27, 2012, at 5:07 PM, jda wrote:

> 
>>> I have a method that uses datediff to determins if a record was created in the last 2 weeks:
>>> 
>>>      dateAdded > datediff( now(), '01/01/1904 00:00:00', 'second' ) - (14 * 24 * 60 * 60) 
>>> 
>>> This works well on US Macs.
>>> 
>>> You told me to use
>>> 
>>>       dateAdded > datediff( now(), '01-01-1904 00:00:00', 'second' ) - (14 * 24 * 60 * 60)
>>> 
>>> for European systems. I checked this by changing my settings to German (in the International System Preferences). But not neither search works.
>>> 
>>> So, what should I use for the day, month, and year for different regions?
>>> 
>> 
>> 
>> I suspect that such a problem will be arisen sooner or later.
>> Actually now() is about local time - so you can not use it worldwide as a timestamp.
>> 
>> Usually UTC time is used for such purposes.
>> But I can not recall - do we have such a function or not.
> 
> Hi Ivan,
> 
> But that's not the problem. It works just fine form my purposes (local time). The problem is the format for the date parameter:
> 
>      01/01/1904
> 
> works if the system language (international setting) is set to English.
> 
> It fails if the language is set to German. I thought
> 
>      01-01-1904
> 
> would work, but the search -> no results (there should be many when the language is German (or English).
> 
> This is all on the same Mac in one time zone, there there should be no issues with now().
> 


Hi Jon,

Actually, it is not related to the language - it is only related to the date-time format property.
And so, if user can set any format himself you can not hardcoded date literals in your queries.

-- 
Best regards,
Ivan Smahin
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macserve.net/pipermail/valentina/attachments/20120628/738f0562/attachment.html>


More information about the Valentina mailing list