# Other Languages > XML, HTML, Javascript, Web and CSS >  [RESOLVED] One line subtract 1 day

## sapator

Hi.


```
   let $dl = $('<dl>').addClass('dl-horizontal');
            $dl.append($('<dt>').text('Ημ. Λήξης'))
            $dl.append($('<dd>').append($('<span>').addClass('pull-right').text(new Date(parseInt(balance.CardExpiry.substr(6))).toLocaleDateString("el"))))
```

is there a way to subtract one day from this in the same line? The .CardExpiry is in the form of /Date(1704060000000)/

Edit:
OK never mind, I fixed it with more lines (if doable with one line,just for educational reason do let me know)



```
            var today = new Date(parseInt(balance.CardExpiry.substr(6)));
            today.setDate(today.getDate() - 1);
            let $dl = $('<dl>').addClass('dl-horizontal');
            $dl.append($('<dt>').text('Ημ. Λήξης'))
            $dl.append($('<dd>').append($('<span>').addClass('pull-right').text(today.toLocaleDateString("el"))))
```

----------


## dday9

Personally, I wouldn't even be doing it with the two extra lines you have added. You are assuming several things which could make it difficult to debug if something goes wrong, for example:
 You are assuming that balance is not null or undefined You are assuming that balance.CardExpiry is not null or undefined You are assuming that balance.CardExpiry is a String and has at least 6 characters You are assuming that everything after the first 6 characters of balance.CardExpiry can be converted to a number You are assuming that the numeric value of everything after the first 6 characters of balance.CardExpiry can be converted to a date

Even though it makes the code a bit lengthier, I would suggest adding some validation checks in there and do something (console.error?) if one of the validations fail.

----------


## sapator

Just to be clear. The code is not mine and there are minimum changes to be done as it's more of a notepad editor fixes.
So yeah, I hear you but it is what it is.

----------


## dday9

Ah, yeah then that changes things.

----------

