3
I get that date from the comic book:
0.002976190476190476
I would like to move to this format: dd/mm/yyyy
, using javascript
pure or jquery
.
How I do?
Here is the ASP that assembles the select:
strsql = ""
strsql = "select a.cod_operadora, a.nom_operadora, to_char(b.dat_exclusao,'dd/mm/yyyy') dat_exclusao, case when b.dat_exclusao is null then 'N' else 'S' end excluido "
strsql = strsql & " from ts_odo.odo_operadora a "
strsql = strsql & " ,ts_odo.odo_prestador_operadora b "
strsql = strsql & "where a.cod_operadora = b.cod_operadora "
strsql = strsql & " and b.cod_prestador_ts = " & cod_prestador_ts
strsql = strsql & "order by to_number(a.cod_operadora)"
set TopDB = server.CreateObject("TSDB.Data")
set rsOperadora = TopDB.objrs ( CStr(txt_usuario), _
CStr(txt_senha), _
CStr(txt_ip), _
session("ace_sistema"), _
CStr(txt_modulo), _
strsql)
set TopDB = nothing
And here is the call to the js method, which is inside a while on Asp:
Response.Write "<script>montaDataSubstituicaoPrestador(" & rsOperadora("dat_exclusao") & ")</script>"
And that’s the js function that should do what I want, print a label at the calculated date.
function montaDataSubstituicaoPrestador(dt_exclusao){
alert('Paulo: ' + dt_exclusao);
var arrData = dt_exclusao.split('/');
var exclusaoFormatada = arrData[1] + '-' + arrData[0] + '-' + arrData[2];
var dias = parseInt(prazoSubPrestador);
var novaData = new Date(arrData[2], arrData[1] - 1, arrData[0]);
novaData.setDate(novaData.getDate() + dias);
hoje = new Date(novaData)
dia = hoje.getDate()
mes = hoje.getMonth()
ano = hoje.getFullYear()
if (dia < 10)
dia = "0" + dia
if((mes+1) < 10)
mes = "0" + (mes+1);
if (ano < 2000)
ano = "19" + ano
var dt = dia + "/" + (mes) + "/"+ano;
var elem = document.getElementById('ind_exclusao_voluntaria');
if(elem.value == 'S')
document.getElementById('lblPrazoSubPrestador').innerHTML = "Prazo de substituição: " + dt;
else
document.getElementById('lblPrazoSubPrestador').innerHTML = "";
}
First you have to identify which logic behind that numeric value represents the date.
– Vinicius Dutra
I could not find anything that would return me this number with the logic UNIX Timestamp, only returns me 1970. But that’s what @Viniciusdutra really said, finding the logic of this number to do.
– Ruggi
@Ruggi, I have no idea how this number is formed. It is a date on the Oracle. Dei um
to_char(data, 'dd/mm/yyyy')
, but it still didn’t work. This select is in a Classic ASP function. I will edit the post and post the function and select it.– pnet
maybe this value is a Javascript timestamp, more details in this link, caso seja isso mesmo, fica fácil fazer o que você quer:
ficaria assim: 

var data = new Date(valorNumericoDoBanco);
var dataFormatada = (data.getDate() > 9 ? data.getDate() : '0' + data.getDate() ) + '/' + (data.getMonth() > 9 ? data.getMonth() : '0' + data.getMonth() ) + '/' + data.getFullYear();
– Vinicius Dutra
When I removed from Asp the tag
<script>
, the date entered normally, but now the javascript function no longer performs.– pnet
So dude, I don’t know much about Sp itself, more about Javascript, and it looks like your Javascript isn’t wrong. You tried to see the logic that @Viniciusdutra quoted?
– Ruggi
Managed to solve?
– durtto