A few days ago I responded to:


>>if a date field is created with legacy tools, can it be used it as a datetime?

>>And an hour field?



>Apparently so:

>

>C_DATE($dOutput)

>C_TIME($dtOutput)

>

>  // Misc is a table created using 4D legacy tool (structure editor)

>

>$sKey:="DateTime Test"

>Begin SQL

>    insert into Misc (sKey, dDate) VALUES (:$sKey, CURRENT_TIMESTAMP());

>

>    select dDate from Misc where sKey = :$sKey into :$dOutput -- yields the 
> date part: 08/31/16 End SQL



>Begin SQL

>     select dDate from Misc where sKey = :$sKey into :$dtOutput  -- yields the 
> time part:  07:24:00 End SQL



>So my statement about needing to create the field with SQL commands is not 
>correct. If you fill a date field using SQL time >stamp 4D will store both the 
>date and time parts either of which may be retrieved using SQL, no matter how 
>the date field >was created.



I neglected to mention that once you add the time value to a 4D field (as 
described above) you can no longer use the equality comparator (=) in queries 
when you are querying with only a date.



If you run the above code to fill the date field with a datetime value the 
following query will fail:



     QUERY([Misc];[Misc]dDate=CURRENT DATE)



That is because 4D is including both the date and the time in the query and 
CURRENT date does include the time part.



So be careful if you start including time in your 4D date fields.



Tom Benedict

Optum Inc

This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to