• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Date convert help

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi code ranch,

I need to get one logic.

For example, I have one Date 03-30-2012. My period is 10 days.

I need to subtract the number 10(Dynamic values may change) from 03-30-2012... The result should be 03-20-2012.

Can anybody help me for fixing this bug.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What bug? You showed no code for a bug.

Did you look at the Date object? It has methods to get the date and its parts. https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date

Eric
 
Loges waran
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hereer is the code:

var notifperiod = a.value;
var expirydate = b.value);
var notifdate = new Date(b.value);
var date1=notifdate.getDate();
notifdate.setDate(date1-notifperiod);

var notifdatefinal = (notifdate.getMonth()+1)+"-"+notifdate.getDate()+"-"+notifdate.getYear();

a.value=notifdatefinal;


In this code, when i enter April 5 as Expiry date and notification period as 10 days. it shows the result of 02-25-2012 It is not showing 03-25-2012.
But for if the difference between Expiry date & notif period occurs in the same month means its working fine.


Suggest me to solve this problem.
 
reply
    Bookmark Topic Watch Topic
  • New Topic