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
 All Forums
 Origin Forum
 Origin Forum
 date to increment of a year

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
5*10 Posted - 08/19/2005 : 11:16:19 AM
Origin Version (Select Help-->About Origin): OriginPro 7G SR4
Operating System:win 2000

Hi,
I have a little problem to find a function, which transform a date in increments of a year or so.
The Date has the format

dd.mm.yyyy hh:mm:ss

It will be nice if the solution of this gives me a value like

0,00145 Years,

or

1234,45 seconds.
Is there a function in Labtalk, OriginC that I can use. If not then I will think about a loop to calculate it.

Greets 5*10
1   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 08/21/2005 : 2:53:07 PM
I can show you how to do this in Origin C, but you probably need Origin 7.5 or later,

 
// assume strDate = dd.MM.year hh:mm:ss format
void dd(string strDate, string strYear)
{
string strDateFormat = "dd'.'MM'.'yyyy hh':'mm':'ss";
double yy;

if( str_to_date_custom(strDate, strDateFormat, &yy) )
{
string strDateRef = "1.1." + strYear + " 00:00:00";
double y0;
if(str_to_date_custom(strDateRef, strDateFormat, &y0))
{
printf("date offset from start of year %s is %g days\n", strYear, yy - y0);
return;
}
}
out_str("error in date format");
}




To test, enter

dd "1.1.2005 23:34:02" 2005

should print out

date offset from start of year 2005 is 0.981968 days

Date is internally represented as Julian Days, so once converted to Julian Days, you can calculate whatever you need to.

CP




The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000