Focal Point
Getting a date out of a timestamp

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9771057762

January 23, 2008, 09:42 PM
serenekk
Getting 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


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
January 23, 2008, 10:53 PM
jimster06
On the upper right of this screen, click on Search the Technical Documentation Library.

Look for things like HPART or HEXTR or HMASK.

HTH


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
January 24, 2008, 03:19 AM
FrankDutch
There 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.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

January 24, 2008, 10:29 AM
jgelona
If 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 



In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
January 25, 2008, 08:43 AM
serenekk
Thanks 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


on VMS: OpenVMS AXP V8.2 Prod and TestEnvironment
Webfocus: WebFocus 7.6.1 Prod and TestEnvironment
January 25, 2008, 09:53 AM
jimster06
If 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


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K