Bij splitting a string an array gives me following values back:
araay[1]=2
araay[2]=9
array[3]=2014
My question is how can i make from these 3 numbers a date 2-9-2014.
If i try:
var date = (array[1]-array[2]-array[3])
the return value is -2021 This is 2-9-2014=2021
var date = new Date (array[1]-array[2]-array[3])
the return value is 2
var date = new Date (array[1]-array[2]-array[3])
the reutrun value is 4-4-1908
So who can solve this?
Read basic string or char functionality for your chosen language.
Also this can be put in a class, predefined or not.
First you can try to use the - as chars instead of operators..
date = array[1] + "-" + array[2] + "-" + array[3]
but you should seriously just look at some documentation..
http://en.cppreference.com/w/
Related
I have a tab in sheets that collects dates from a scheduling application. All the values in Appointments!C:C are dates. I am trying to bring those dates to another tab, but some of the values seem to be converting into non-dates, while some stay as dates.
i am using the following script:
if(AppWO==OpenWO)
{
var Appdate1 = new Date(AppRange[i][3]) // this gets the date value from sheet ss1
var DateString1 = ("0" + Appdate1.getDate()).slice(-2) + "-" + ("0"+(Appdate1.getMonth()+1)).slice(-2) + "-" + Appdate1.getFullYear() //this breaks up and reforms the value
ss0.getRange(j+2,24,1,1).setValue(DateString1) //this puts the date in sheet ss0
}
The problem is that 'DateString1' on sheet ss0 seems to not always be a date value. Do I need to do something differntly to use setValue() when working with dates?
I'm trying to pass a date to a function in Kotlin. I don't want to have to type "08/30/2018" as a String and would instead prefer Date. I initially tried just 08/30/2018 but get a compiler stating an Integer was found for the input rather than Date.
var myDate = 1/1/2000
var newDate = 08/30/2018
fun setDate(value: Int){
myDate = value
}
setDate(newDate)
println(newDate) //0
println(myDate) //0
println(myDate.compareTo(newDate)) //0
Why does Kotlin accept 08/30/2018 as an int? Why is it stored correctly to another int variable but then print 0 when the value is retrieved?
How can I initialize a variable to a date like 1/1/2000 and then set another date later on? I haven't found anything about passing a date anywhere unless it is a String.
When you assign 8/30/2018 to a variable then the compiler recognizes it as integer division 8/30 which is 0 and then /2018 and the result is 0.
You could do it like val date = Date("1/1/2000") but this is now deprecated
You can use the Java 8 Date/Time API instead:
val date = LocalDate.of(2000, 1, 1)
you can find more here:
https://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html
Hi I am a newbie and have a problem I have been trying to solve for weeks. I have a table imported from excel with dates in text format (because dates go back to 1700s) Most are in the format "mmmyyyy", so it is relatively easy to add "1" to the date, convert to date format, and sort in correct date order. The problem I have is that some of the dates in the table are simply "yyyy", and some are empty. I cannot find an expression that works to convert these last two to eg 1 Jan yyyy and 1 Jan 1000 within the same expression. Is this possible, or would I need to do this in two queries? Sorry if this question is very basic - I cannot find an answer anywhere.
TIA
You can do something like:
Public Function ConvertDate(Byval Expression As Variant) As Date
Dim Result As Date
If IsNull(Expression) Then
Result = DateSerial(1000, 1, 1)
ElseIf Len(Expression) = 4 Then
Result = DateSerial(Expression, 1, 1)
Else
Result = DateValue(Right(Expression, 4) & "/" & Left(Expression, 3) & "/1")
End If
ConvertDate = Result
End Function
I am newbie in Progress and I've Trouble in date function Progress 4gl.
Example I have string value = '2016 '.
How do I put that value into a date in Progress?
Example:
def var xx as char.
def var xq as date.
ASSIGN
xx = '2016'
xq = DATE(01/01/xx).
While it is possible to write
ASSIGN
xx = '2016':U
xq = DATE('01/01/':U + xx)
.
I would prefer
ASSIGN
xx = '2016':U
xq = DATE(1,1,integer(xx))
.
(The first example is dependent on the current date format. If you look up the DATE function in the OpenEdge Help you can see that DATE ( month, day, year ) is valid, too.)
I have a Date string of following format:
'31-OCT-2013'
How do I convert this into Date of following format using Extjs 4:
'08/31/2013'
I am using IE8.
If you have string "31-OCT-2013", you need to:
Convert it into date object
var myDate = Ext.Date.parse("31-OCT-2013", 'd-M-Y');
Format it to as you want
Ext.Date.format(myDate, 'm/d/Y');
Try something like this:
If your day representation would be 2 digit with leading zero, then apply this
var date = Ext.Date.parse("31-OCT-2013", 'd-M-Y');
console.log(Ext.Date.format(date, 'm/d/Y'));
But if your day representation would be without a leading zero, then apply this
var date = Ext.Date.parse("31-OCT-2013", 'j-M-Y');
console.log(Ext.Date.format(date, 'm/d/Y'));
Check the docs for Ext.Date