Solved

Extract datetime from string

Posted on 2004-09-06
6
464 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies 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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

630 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