Solved

Extract datetime from string

Posted on 2004-09-06
6
437 Views
Last Modified: 2012-05-05
Hi,
I´m using SAPDB

I have a databasecolumn with values like
add: 01.01.04 22:11:06 rem:01.02.04 22:00:00
add: 02.01.04 22:12:16 rem:02.02.04 23:23:23
add: 03.01.04 22:21:46 rem:03.02.04 00:45:42

and i want to check if the current date (  now()  ) is bigger then the value after add: and smaller than the value after rem:
so i extract the strings with
substr(VWHB,5,17)
substr(VWHB,27,17)  

and thought i could do something like convert() or date() but i cant get the right statement.
I allways get errors.
i tried to change the order in the string
(2004-01-01 22:22:06)
i tried to add millis
(2004-01-01 22:22:06.000)
or 6 millis :-)
(2004-01-01 22:22:06.000000)

the date function works if i only use the date(2004-01-01), but i need the time too.
Can somebody help me?
0
Comment
Question by:Koma666
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
erhanyayli earned 125 total points
ID: 11989704
Hi

1)
in order to select use:

select
to_date(substr(c1,6,17),'DD.MM.YY HH24:MI:SS') add_val,
to_date(substr(c1,38,17),'DD.MM.YY HH24:MI:SS') rem_val

2)

in order to compare with sysdate use

select * from table
where sysdate>to_date(substr(c1,6,17),'DD.MM.YY HH24:MI:SS') and sysdate<to_date(substr(c1,38,17),'DD.MM.YY HH24:MI:SS')

Regards,
Erhan
0
 
LVL 5

Author Comment

by:Koma666
ID: 11989818
i just get the error that the function to_date is unknown.
0
 

Assisted Solution

by:GERALDFOOTE
GERALDFOOTE earned 125 total points
ID: 11992827
LOOK AT THE VFP COMMANDS

YEAR(DATETIME()) OR YEAR(DATETIMEIS)
MONTH(DATETIME()),
DAY(DATETIME())
HOURS(DATETIME())
MINUTE(DATETIME())
SEC(DATETIME())


DATETIME(2004,11,24,12,0,0)

THESE COMMANDS WILL ALLOW COMPLETE  CONTROL OF DATE AND TIME INFORMATION
0
 
LVL 5

Author Comment

by:Koma666
ID: 12187514
I switched the code and now i´m doing all the date and time things with java.

@cleanup
please give erhanyayli 100 points
and GERALDFOOTE 50 points for assistance.
please send the rest back to me.
thx
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question