Hi,
How to concatenate date and time like this 2018-09-22 03:59:00
Regards
R karthik
Hi karthik R,
Concatenate Date and Time using JavaScript.
1) Add JQuery script in the Screen level.
SyntaxEditor Code Snippet
$(document).ready(function() { var sysDateTime = new Date(); var month = sysDateTime.getMonth() + 1; var time = (sysDateTime.getHours() < 10 ? '0' : '') + sysDateTime.getHours() + ':' + (sysDateTime.getMinutes() < 10 ? '0' : '') + sysDateTime.getMinutes() + ':' + (sysDateTime.getSeconds() < 10 ? '0' : '') + sysDateTime.getSeconds(); var date = sysDateTime.getFullYear() + '-' + (month < 10 ? '0' : '') + month + '-' + (sysDateTime.getDate() < 10 ? '0' : '') + sysDateTime.getDate(); $('input[id$="DateTimeInput"]').val(date + ' ' + time); });
2) Input Widget with Name - DateTimeInput
3) In the page I introduced a button (for testing purpose) below the input widget, which on click will convert the text value of input widget to datetime using TextToDateTime(DateTime). Here DateTime is the local variable (Text - datatype) assigned as the variable to the input widget.
4) On button click the DateTime value is getting successfully converted to the date time as the Outsystems default datetime format. After this you can pass the converted value as a parameter to table record create action.
Hope you understood my implementation.
Thanks & Regards,
Benjith Sam
Another basic implementation. Concentration of Date and Time in expression.
Local Variable (Default Value):
Date = CurrDate()
Time = CurrTime()
Expression value:
Date + " " + Time
I'm not sure what exactly you want to achieve, but this how you can concatenate date and time (still many ways to do this).
Regards,
FormatDateTime(NewDateTime(Year(Date),Month(Date),Day(Date),Hour(Time),Minute(Time),Second(Time)),"yyyy-MM-dd hh:mm:ss")
You can just use these outsystems function if you have date and time in two different variable
karthik R wrote:
Hi Karthik,
Need some more inform from your side. You told us about value what will be the input value.
In OS we have different inbuilt function to get 2018-09-22 03:59:00 output value.
You only concatenate the value then you can use Var3 = Var1 + " " + Var2
Case 1-
Var1 = Datetime & Var2 = Datetime
Var 3 = DateTimeToDate(Var1)+ " "+ DateTimeToTime(Var2)
Case 2 -
Var1 = Datetime & Var2 = time
Var 3 = DateTimeToDate(Var1)+ " "+ Var2
Case 3 -
Month = M, Day = D, Year = Y, Hour = H, Min = M, Sec = S
Var 3 = Use below one
NewDateTime(Y,M,D,H,mi,s)
Karthik, you can choose according to your requirments.
Thanks,
Rajat Agrawal