Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Extract datetime from string

Posted on 2004-09-06
6
Medium Priority
?
473 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 500 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
In this article, we’ll look at how to deploy ProxySQL.
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…

719 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