January 23, 2008, 09:42 PM
serenekkGetting a date out of a timestamp
How do I get a date out of the timestamp that looks like this:
Friday, January 18, 2008 10:00:03 PM EST
so from here I only want the Jan 18,2008 maybe as JAN 18 2008 so that I can sort by that date and use it in where statement etc?
Thanks in advance!
KK
WF 7.1.6
January 23, 2008, 10:53 PM
jimster06On the upper right of this screen, click on Search the Technical Documentation Library.
Look for things like HPART or HEXTR or HMASK.
HTH
January 24, 2008, 03:19 AM
FrankDutchThere is a very good book available for 25 U$.
It's called "(Almost) 101 Ways to Work With DATES in WebFOCUS" ISBN978-0-9791722-1-2
You can order it ad Information Builders.
How to convert your date time field depends on many things.
If this date in fact is an alpha string, you can handle it as an alpha sting and split it.
If this is only a way to present the date and in the database it is in fact a number, you van use that number.
January 24, 2008, 10:29 AM
jgelonaIf your string is a display of a data base date-time stamp, just use the HDATE function. If you are using DevStudion, you can find all the info on all the functions under Help.
If it is really a string and you want to sort on the date, I would recommend converting it to a smart date. You will have to use a variety of functions. For example, here's one way:
DEFINE FILE CAR
INPUT_DT/A42='Friday, January 18, 2008 10:00:03 PM EST';
TESTMD/A12=UPCASE(12,EDIT(GETTOK(INPUT_DT,42,2,',',13,'A13'),'$999999999999'),'A12');
TESTMT/A3=EDIT(TESTMD,'999');
TESTM/A2=DECODE TESTMT(JAN 01 FEB 02 MAR 03 APR 04 MAY 05 JUN 06 JUL 07
AUG 08 SEP 09 OCT 10 NOV 11 ELSE 12);
TESTD/A2=GETTOK(TESTMD,12,2,' ',2,'A2');
TESTYY/A4=EDIT(GETTOK(INPUT_,42,3,',',5,'A5'),'$9999');
TESTYYMD/YYMD=DATECVT(TESTYY|TESTM|TESTD,'A8YYMD','YYMD');
END
-*
TABLE FILE CAR
PRINT INPUT_DT TESTMD TESTMT TESTM TESTD TESTYY TESTYYMD
BY COUNTRY NOPRINT
IF RECORDLIMIT EQ 1
END
yields:
PAGE 1
INPUT_DT TESTMD TESTMT TESTM TESTD TESTYY TESTYYMD
---------------------------------------- ---------- ------ ----- ----- ------ ----------
Friday, January 18, 2008 10:00:03 PM EST JANUARY 18 JAN 01 18 2008 2008/01/18
January 25, 2008, 08:43 AM
serenekkThanks so much for all the replies.
Jgelona,
Thanks so much as well. I have exactly the same method as far as using gettok and getting day and month etc. I was also thinking of decoding the month like you are doing it here, so I am on the right direction. Thanks for the last datecvt function. This is exactly what I want.
Thankssssss so much. so that with that converted date, I can do the where statement on it.
KK
January 25, 2008, 09:53 AM
jimster06If you are using a date in a WHERE statement, consider the DT(date-time stamp) expression; something like WHERE DATE-TIME in data GE DT(DATE-TIME ARGUMENT).
And I concur with the recommendations re
Almost 1001 Ways