Re: How to convert date to integer or vice versa

2022-08-09 Thread David Samson via 4D_Tech
I think this is what you are looking for:

https://kb.4d.com/assetid=28510

David


> I have two fields in a table which must contain the same information.
> One is date, the other an integer.
> Rather than entering the same information twice, I would like to enter it
> in one field and have 4d fill the other field automatically.
> Can you help with the proper method to do so.
> Thank you.
>
>
-- 
D Samson
**
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: How to convert date to integer or vice versa

2022-08-08 Thread Keith Goebel via 4D_Tech
Stephane,
I no longer have access to Design mode as I am retired and have let my 4D 
Partner license lapse so I’m unable to check out the latest date/number 
commands.
That said, I used to store dates as numbers in a way that sorted the numbers 
chronologically. 
I did that by extracting the day, month and year from the date and then 
combined them into a number by doing something like:
Number = 2 digit year x 10,000 + month x 100 + day
Incidentally, I think 4D doesn’t actually use integers now - all are longints 
and I used those to store numeric dates.
Hope this helps, Keith
There are 3 kinds of mathematician. Those who can count, and those who can't.


> On 9/08/2022, at 11:20 AM, Stephane Potvin  wrote:
> 
> Hello Keith,
> 
> Thank you for your reply.
> 
> I am indeed old school with 4D. I started at version 3. :-)
> 
> I am indeed looking for a simple way to populate the field with a method.
> Any idea what code would look like?
> 
> Thank you,
> 
> Stephane
> 
>> On Aug 8, 2022, at 18:13, Keith Goebel  wrote:
>> 
>> Hi Stephane,
>> Thinking in ”old-school” 4D code, using a trigger can be a good way to 
>> enforce a field population rule but an alternative is to create the date 
>> field’s object method and populate the integer from there. The code may well 
>> be easier to find and maintain from there.
>> If you need help to do the actual conversion (and ‘de-conversion’ if that’s 
>> a word) I’m sure you’ll get plenty of suggestions if you ask.
>> HTH, Keith
>> 
>>> Date: Sun, 7 Aug 2022 22:51:20 -0400
>>> From: Stephane Potvin 
>>> To: 4D iNug Technical <4d_tech@lists.4d.com>
>>> Subject: How to convert date to integer or vice versa
>>> 
>>> I have two fields in a table which must contain the same information.
>>> One is date, the other an integer.
>>> Rather than entering the same information twice, I would like to enter it 
>>> in one field and have 4d fill the other field automatically.
>>> Can you help with the proper method to do so.
>>> Thank you.
>>> 
>>> --
>>> Date: Mon, 8 Aug 2022 02:59:27 +
>>> From: Keisuke Miyako 
>>> To: 4D iNug Technical <4d_tech@lists.4d.com>
>>> Subject: Re: How to convert date to integer or vice versa
>>> 
>>> triggers!
>>> 
>>> https://doc.4d.com/4Dv19R5/4D/19-R5/Triggers.300-5831495.en.html
>>> 
>>> Can you help with the proper method to do so.
> 

**
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: How to convert date to integer or vice versa

2022-08-08 Thread Keith Goebel via 4D_Tech
Hi Stephane,
Thinking in ”old-school” 4D code, using a trigger can be a good way to enforce 
a field population rule but an alternative is to create the date field’s object 
method and populate the integer from there. The code may well be easier to find 
and maintain from there.
If you need help to do the actual conversion (and ‘de-conversion’ if that’s a 
word) I’m sure you’ll get plenty of suggestions if you ask.
HTH, Keith

> Date: Sun, 7 Aug 2022 22:51:20 -0400
> From: Stephane Potvin 
> To: 4D iNug Technical <4d_tech@lists.4d.com>
> Subject: How to convert date to integer or vice versa
> 
> I have two fields in a table which must contain the same information.
> One is date, the other an integer.
> Rather than entering the same information twice, I would like to enter it in 
> one field and have 4d fill the other field automatically.
> Can you help with the proper method to do so.
> Thank you.
> 
> --
> Date: Mon, 8 Aug 2022 02:59:27 +
> From: Keisuke Miyako 
> To: 4D iNug Technical <4d_tech@lists.4d.com>
> Subject: Re: How to convert date to integer or vice versa
> 
> triggers!
> 
> https://doc.4d.com/4Dv19R5/4D/19-R5/Triggers.300-5831495.en.html
> 
> Can you help with the proper method to do so.
**
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: How to convert date to integer or vice versa

2022-08-07 Thread Keisuke Miyako via 4D_Tech
triggers!

https://doc.4d.com/4Dv19R5/4D/19-R5/Triggers.300-5831495.en.html

Can you help with the proper method to do so.

**
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

How to convert date to integer or vice versa

2022-08-07 Thread Stephane Potvin via 4D_Tech
I have two fields in a table which must contain the same information.
One is date, the other an integer.
Rather than entering the same information twice, I would like to enter it in 
one field and have 4d fill the other field automatically.
Can you help with the proper method to do so.
Thank you.
**
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**