0

I receive this date(number) from Oracle database

0.002976190476190476

I'd like to change to this format: dd/mm/yyyy, using Javascript or jQuery.

How can I do?

Adam Azad
  • 11,171
  • 5
  • 29
  • 70
  • Is that a date or a timespan? I've not seen a date format which uses a floating point before. – Rory McCrossan Jan 04 '16 at 17:14
  • @RoryMcCrossan, it's a date. I receive this way from database. –  Jan 04 '16 at 17:17
  • Can you also tell what datetime it is? Refer following [post](http://stackoverflow.com/questions/10319935/timestamp-conversion-in-oracle-for-yyyy-mm-dd-hhmmss-format) for reference. – Rajesh Jan 04 '16 at 17:17
  • @Rajesh, we use this format in Brasil. –  Jan 04 '16 at 17:24
  • My apologies, I meant, in JS timestamp `1451928337920` means `Mon Jan 04 2016 22:55:37 GMT+0530 (IST)`. So what datetime does this timestamp represents – Rajesh Jan 04 '16 at 17:26
  • @Rajesh, 04/01/2016 - This is the format desired –  Jan 04 '16 at 17:28
  • Are you sure the date (number) is correct? Shouldn't it be `> 0` or No of secs. in a year: `31536000000`? – Rajesh Jan 04 '16 at 18:02
  • @Rajesh, yes. I'm sure. –  Jan 04 '16 at 18:06
  • @pkt then I guess you will have to manually parse it. In such cases, I would recommend you to do it on database only, but if you want to try in JS, you can try something like **[this](https://jsfiddle.net/RajeshDixit/t2sgtd6d/1/)**. – Rajesh Jan 05 '16 at 07:01

1 Answers1

0
DECLARE @x NUMERIC(10,0);

SET @x = 20110501;

SELECT CONVERT(DATETIME, CONVERT(CHAR(8), @x));

Result

2011-05-01 00:00:00.000
animuson
  • 53,861
  • 28
  • 137
  • 147
Nikita
  • 75
  • 4
  • I'm guessing from the jQuery and Javascript tags, the OP wants to do it on the client. – Rory McCrossan Jan 04 '16 at 17:21
  • Nikita, this way i'm go to convert in the database, but i need to convert it in my application. –  Jan 04 '16 at 17:26
  • I have edited my comment. Also, found one more useful link - http://www.mattkruse.com/javascript/date/source.html – Nikita Jan 04 '16 at 17:29