Macros and Programming


CardboxForumsMacros and Programming > "changing date and time to -12 h (astronomy!)"

changing date and time to -12 h (astronomy!)

Current user: [none]
Register / Log In · Help

Posted By Post


20-Aug-2011 13:21

I am scripting my astronomy observatory, Carbox makes slewing a telescope to objects, start pictures, and stores them.
Works wonderfully (as usual, everything seems possible with Cardbox, my basic use is running my Patient files in my medical practice since 20 years)
To keep pictures stored by date, the date should not change at 24H midnight, but at 12H, at noon... avoiding pictures of one night to be stored in two directories.
If i make a macro:

Fields("ASTRODATE")=DateAdd("h",-12,Fields("DATE")) it does not work, however +24 changes one day..

Is there a simple solution ?



20-Aug-2011 14:36

There is a solution.
In field Date:
- Is it a date that is in all records same format?
- Which is the format of that date/time?


20-Aug-2011 16:10

Hi Bert,

We start the telescope, read the coordinates of a galaxy, set the date, take a picture and store it. If there is a supernova, the differences in the images will tell. So images should have the same name, but should be in a directory that is created , based on the date. As imaging will take hours, the date will change during the night.
the records are validated to today as soon as read, so a group of selected records will have the same date (except when the script continues after midnight). To easily store new directories, the date is stored in the format: "le 21 août 2011" , but i can convert the date and keep it in another field if needed. In principle, all records have the same date-format.

The macro could in the beginning set the whole selection to the actual date, to keep all images together, but that would give a problem if one night we start at 01H00 and next night we start at 23H00 !

So how to set back the date for 12 hours?



20-Aug-2011 16:54

I tried:

x = "24/10/2003 10:49:38"
msgbox DateToCardbox(DateAdd("h", -12, x),"04/07/1976")

The result in the msgbox is 23/10/2003.
Is suppose that you can use this sample.

Perhaps locales can be disturb this. Then this must be first line (in case of the Netherlands)




20-Aug-2011 20:18

Bert, it works in your example, but if Cardbox fills in the date and time by validation, i do this:
Type "{*Date <1036>4/7/1976.01.02.03}" (in validation)

i copy this field to your x, and ask a messagebox to echo x: it says:
 21/8/2011.22.10.25 (it is 22h10m25 at my watch)
and not a blank nor a : as separator as you used.

Regards (groeten)



20-Aug-2011 20:23

Sorry Bert,

I noticed that if i validate with :

Type "{*Date <1036>4/7/1976 01:02:03}"

it works perfectly ! not very well documentated in the manual, but thanks again !

Best regards,


Quick Reply

Please log in or register before trying to post a reply.

© 2010 Cardbox Software Limited   Home