DBTIME and time date types 
Author Message
 DBTIME and time date types


Quote:
> I am being passed in a character string which contains a
> date/time in the following format:
>   YYYY-MM-DD HH:MM:SS

> ex: 1998-05-18 09:05:00

> I need to convert it such that it looks like the below:
>    Mon May 18 09:05:00 EDT 1998  <-- output like that of unix time()

> I would like to know if there is an easy way to do the above.

No, not really.

Quote:
> I am able to obtain the above format except for the day of the week
> and the time zone by making calls to dtcvasc() to convert to a
> datetime, and then using dttofmtasc() with formatting.  Is there a
> general utility either in Informix or in C that can allow me to
> print the day of the week??

I'd probably convert the string into a datetime, then convert the
datetime into the number of seconds since 1970-01-01 00:00:00, and
then use localtime(3) or gmtime(3) to convert to a struct tm, and
then, finally, strftime(3) to convert and format the string.  That's a
long-winded sequence.  Alternatively, if strptime() is available on
your platform, use strptime(3) to do the input conversion direct to
struct tm format.

strftime() has both %Z for the time zone name and %a for abbreviated
day name, as you require.  I thought dttofmtasc() probably did too,
but I see it does not.  Remember that the DATETIME value does not have
a timezone explicitly associated with it, which makes life kinda hard.

Yours,

Guardian of DBD::Informix -- see http://www.***.com/



Wed, 18 Jun 1902 08:00:00 GMT
 DBTIME and time date types

This is a multipart message in MIME format

--------------InterScan_NT_MIME_Boundary
Content-Type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: quoted-printable

     With ESQL 7=2E23=2EUC1, (and possibly earlier versions), you can do
    =20
     dttofmtasc(&dtval, outstr, sizeof(outstr), "%a %b %e %H:%M:%S %Y");
    =20
     which will give you exactly what you want, but without the timezone=2E=
 =20
     The timezone is difficult because you have no way of knowing if a=20
     particular date is in daylight saving time (if you have that where you=
=20
     are)=2E  You could get the TZ variable from Unix, however, and use tha=
t=2E
    =20
     HTH
     Davin

______________________________ Reply Separator ____________________________=
_____
Subject: DBTIME and time date types

Date:    30/06/1998 21:44

hello,
    =20
I am being passed in a character string which contains a=20
date/time in the following format:
  YYYY-MM-DD HH:MM:SS
    =20
ex: 1998-05-18 09:05:00
    =20
    =20
I need to convert it such that it looks like the below:
   Mon May 18 09:05:00 EDT 1998  <-- output like that of unix time()
    =20
    =20
I would like to know if there is an easy way to do the=20
above=2E I am able to obtain the above format except
for the day of the week and the time zone by making=20
calls to dtcvasc() to convert to a datetime, and then=20
using dttofmtasc() with formatting=2E Is there a general=20
utility either in Informix or in C that can allow me to=20
print the day of the week??
    =20
Thanks,

    =20
-----=3D=3D Posted via Deja News, The Leader in Internet Discussion =3D=3D-=
----=20
http://www=2Edejanews=2Ecom/rg_mkgrp=2Exp   Create Your Own Free Member For=
um
    =20

**********************************************************************
DST International   Tel:+44 181 390 5000    www=2Edstinternational=2Ecom=20

This message and any attachments to it is intended only for the=20
individual or company to which it is addressed and may contain=20
information which is privileged, confidential or prohibited from=20
disclosure or unauthorised use=2E  If the recipient of this=20
transmission is not the intended recipient, or the employee or agent=20
responsible for delivering such materials to the intended recipient,=20
you are hereby notified that any use, any form of reproduction,=20
dissemination, copying, disclosure, modification, distribution and/or=20
publication of this e-mail message or its attachments other than by=20
its intended recipient is strictly prohibited by the sender=2E =20

If you have received it in error, please notify us immediately by=20
telephone on the number above and destroy the message and all copies=20
in your possession=2E
**********************************************************************

--------------InterScan_NT_MIME_Boundary--



Wed, 18 Jun 1902 08:00:00 GMT
 DBTIME and time date types

Quote:

> hello,

> I am being passed in a character string which contains a
> date/time in the following format:
>   YYYY-MM-DD HH:MM:SS

> ex: 1998-05-18 09:05:00

> I need to convert it such that it looks like the below:
>    Mon May 18 09:05:00 EDT 1998  <-- output like that of unix time()

> I would like to know if there is an easy way to do the
> above. I am able to obtain the above format except
> for the day of the week and the time zone by making
> calls to dtcvasc() to convert to a datetime, and then
> using dttofmtasc() with formatting. Is there a general
> utility either in Informix or in C that can allow me to
> print the day of the week??

Get my submission to the IIUG Software Repository named datelib_ak.  It
contains a function, getdate, which will accept text date input in
freeform and returns a struct timeval which contains a UNIX time_t and
number of microseconds since the last second.  You can then pass the
time_t component to localtime() to get a struct tm which, in turn, can
be passed to asctime to get the string format you desire.  Getdate()
accepts VERY loose freeform dates anything from the Informix datetime
output format (ie ANSI dates) to something like "3 days 4 hours 12
minutes after yesterday" are accepted and converted to reasonable
results.  The example given returns "Fri Jul  3 14:28:28 1998" at
10:16:28 today, July 1, 1998 localtime using the test main() provided.

Art S. Kagel



Wed, 18 Jun 1902 08:00:00 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. MySQL ODBC - Coverting Access date/time type to MySQL date/time type

2. Feature-request: allowing the date/time type to accept ISO8601 compliant date/time combinations on input

3. INGRES date data type vs Standard Time/Daylight Savings Time change

4. java.sql.Date, Time, and TimeStamp with Oracle date type

5. Help: using DBTIME to load different time formats

6. java Date/Time-->MSAccess Date/Time?

7. ADO with Access Date/Time field not storing the time, just the date

8. Getting Date/Time from LAN Machine and Setting Date/Time on Client

9. how to change dates or times in a oracle date time field

10. Calculate difference between start date and time and end date and time

11. Unix time/date => Pick time/date

12. convert char data type to date time


 
Powered by phpBB® Forum Software