Solved

Extract datetime from string

Posted on 2004-09-06
6
450 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
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…

685 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