getdate...

L

lasek

Hi all,
Someone can help me ?

Code:
char compete[FIELD_LENGTH]; //20 char

compete contain a 'date value' returned from oracle procedure (Pro*C)and
you can imagine his value, for example,"01/01/2005"

After i call

strcpy(compete,FormattaData(compete,"%Y%m"));

Now compete value is "2005-01-01"

char *FormattaData(char*datak, char *format)
{
        static struct tm *tm;
        static char buf[20];
        char messaggio[200];
        char messtail[100];

        memset(buf,'\0',sizeof(buf));

        if((tm = getdate(datak))== NULL)
        {
                CreaPattern(messaggio);
                sprintf(messtail," Forse manca la stringa di decodifica in
getdate.template %s \n",datak);
                strcat(messaggio,messtail);
                ScriviLogFile(messaggio,0);
                sprintf(buf,"");
        }
        else
        {
                strftime(buf,sizeof(buf),format,tm);
        }

        buf[19] = '\0';

        return buf;
}

I don't wont to use getdate() because this function get info from a
template used to parse and interpret the input string. The templates are
contained in a text file identified by the environment variable DATEMSK,
and my
application run very slowly each time i call her

Someone can help me ?

Thanks a lot..
 
L

Lawrence Kirby

Hi all,
Someone can help me ?

Code:
char compete[FIELD_LENGTH]; //20 char

compete contain a 'date value' returned from oracle procedure (Pro*C)and
you can imagine his value, for example,"01/01/2005"[/QUOTE]

If you want to convert a string like that with a well-defined format into
a struct tm you could use sscanf().
[QUOTE]
After i call

strcpy(compete,FormattaData(compete,"%Y%m"));

Now compete value is "2005-01-01"[/QUOTE]

Your format string didn't include the day of the month.

Lawrence
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top