The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Date formating in GetNBox
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

memorialsb

USA
Posts

Posted - 10/18/2004 :  4:50:49 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): v7.5853
Operating System: Win 2000

Quick question,

Is there a way to drop a date format on a GetNBox dialog?

I want to do something like this:

Dialog Title
------------
Worksheet: Data1
Date of aquisition: 10/18/04
Elapsed days: <10/18/04 - StdDate>
<Other Data & fields ....>


Essentially I'm creating a dialog with the GetN_Tree that the user would specify when the data was acquired, and the dialog would automatically update (or at least be able to compute internally) how many days have elapsed since a standard date. The dialog then goes on with other fill in the blank sorts of questions.

I've thought about trying to convert the string to a time_t and subtracting that way, but it seems like a lot of trouble unless there was an easier way through OriginC or LabTalk.

-Matt


Matthew Meineke
mmeineke@memoralsb.org

Edited by - memorialsb on 10/18/2004 4:57:18 PM

cpyang

USA
1406 Posts

Posted - 10/18/2004 :  5:16:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I am afraid you will need to do this using strings for now. We are planning to make this easier in Origin8, but for the time being, consider the following functions that you have access to,

1. converting a date string (short format) into Julian Day

str_to_date_custom

2. convert a Julina Day (double) into a string
date_to_str_custom

or use LabTalk notation "Dn" where n is the index into date format drop down

DoubleToStr(dVal, szBuff, nBuffSize, "D9");


CP





Edited by - cpyang on 10/18/2004 8:00:08 PM
Go to Top of Page

memorialsb

USA
Posts

Posted - 10/18/2004 :  6:14:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks,

Test code pretty much works as expected:


string dateFrmt = "MM'/'dd'/'yyyy";
string stdDate = "9/21/2004";
string dateAcquired = "10/18/2004";

double stdDateVal;
double dateAcquiredVal;
double diff;

str_to_date_custom(stdDate, dateFrmt, &stdDateVal);
str_to_date_custom(dateAcquired, dateFrmt, &dateAcquiredVal);

diff = dateAcquiredVal - stdDateVal;

printf( "stdDate = %lf;\n"
"dateAcquired = %lf;\n"
"diff = %lf days\n",
stdDateVal, dateAcquiredVal, diff );


Gives the following:


stdDate = 2453269.000000;
dateAcquired = 2453296.000000;
diff = 27.000000 days


So this will work for now.

-Matt

Matthew Meineke
mmeineke@memoralsb.org
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000