string date to DATE format

Posted By: ganimedes

string date to DATE format - 04/27/20 18:29

Hello. I'm trying to create a dataSet of just 1 record with some data in T6 format. So I use the dataNew function that provides me a pointer

T6 *t = dataNew(1, 1, 7); // Handler 1, 1 record, 7 fields

I assign the pointer to a T6 struct. Then try to fill it with some OHLC data. The first one is the date so I try:

t->time = ...

but I don't know how to convert a string containing the current date (example 2020-04-27 00:00) to the DATE format. According to documentation: The DATE format is equivalent to a double / var variable and counts the number of days since 12-31-1899 with a resolution of ~ 1 µsec.

To provide some context (maybe I'm not following the right path) I'm trying to add a OHLC row to an existing t6 file. My idea to achieve this is:

1. dataLoad of the existing t6 file to create a dataSet in memory

2. create a new dataset with 1 record

3. populate it with today's OHLC data

4. dataAppend of the second dataset to the first one

5. dataSave of the first dateset with the added row

Thanks in advance
Posted By: jcl

Re: string date to DATE format - 04/28/20 09:35

For the current date, use t->time = wdate(NOW);.

https://manual.zorro-project.com/month.htm
Posted By: ganimedes

Re: string date to DATE format - 05/01/20 07:57

Thanks.

I finally use wdatef("%Y%m%d", dateToday) , where dateToday is a string containing the current day.

Yours is much shorter!
© 2024 lite-C Forums