473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Converting Timestamp to date.

3
Hey
I am trying this
create or replace FUNCTION DatesPast
(
v_dueDate Timestamp
)
RETURN NUMBER
AS
DaysPast DATE
BEGIN
TO_DATE(v_dueDate; 'yyyymmdd');
IF (v_dueDate > SYSDATE) THEN
DaysPast :=SYSDATE - v_dueDate ;
END IF;
RETURN DaysPast;
END

I have to convert input date of type timestamp to date type than subtract it from sysdate.and get the result of differnece between days only.
But i get error msg that to_date() is invalid.
I know syntax is wrong somewhere.Can nyone guide me through this.
Jul 3 '07 #1
2 2491
Yash3
3
return Number is wrong for now.It should be RETURN DATE
Jul 3 '07 #2
debasisdas
8,127 Expert 4TB
Expand|Select|Wrap|Line Numbers
  1. create or replace FUNCTION DatesPast
  2. (
  3. v_dueDate Timestamp
  4. )
  5. RETURN number
  6. AS
  7. dd date;
  8. DaysPast number;
  9. BEGIN
  10. select trunc(cast(v_dueDate as timestamp)) into dd from dual;
  11. IF (dd > SYSDATE) THEN
  12. DaysPast :=dd-SYSDATE ;
  13. RETURN DaysPast;
  14. else
  15. DaysPast :=dd-sysdate ;
  16. RETURN DaysPast;
  17. END IF;
  18. END;
  19.  
Hope that is what you were looking for.
Jul 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Kit | last post by:
Howdy! I have some dates in a MySQL database that are in a 'Y-m-d' format. Is there a way to have PHP read these dates and convert them to a 'd-M-Y' format?
13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
0
by: Andy Turner | last post by:
I've just been trying to do this. I looked on Google and it seems to be a common problem with no obvious solution. I've seen various solutions which don't seem exactly elegant, so I figured I'd...
1
by: news.microsoft.com | last post by:
In vb.net, is there anyway to convert a SQL timestamp field into a real date. Also can I convert a real date into a SQL timestamp
3
by: Tgone | last post by:
Hello, I need to convert a MySQL date "2007-03-08", into "March 8th, 2007". Normally I would use MySQL to accomplish this task but I have to use PHP. Here's my code: echo date("F jS, Y",...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
6
by: marc | last post by:
hi im trying to convert Date() into a unix timestamp so i can stick the result into a mysql db, please help!
7
by: bdbeames | last post by:
I never used Perl before, so I need a little help formating a date. What I'm doing is querying a postgres database and then creating a .xml file for a RSS feed. I don't know how to correctly format...
5
by: Hemant Shah | last post by:
Folks, How can I convert date/time/timestamp to an integer? According to UDB 8.1 docs that I have, INTEGER('1964-07-20') should return 19640720, but when I run the SQL statement I get...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.