Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 489
  • Last Modified:

Extract datetime from string

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
Koma666
Asked:
Koma666
  • 2
2 Solutions
 
erhanyayliCommented:
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
 
Koma666Author Commented:
i just get the error that the function to_date is unknown.
0
 
GERALDFOOTECommented:
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
 
Koma666Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now