I'm using PowerBuilder 10.5 and I have two single line edit (SLE) fields - sle_date1 and sle_date2 on my window.
What I need is for those two fields to be filled once I open my program. sle_date2 has to have the value of today (for example - 09.07.13), and sle_date1 has to have the value of (sle_date2-30 days) (example 09.06.13).
So, as I said, once I open my programs both fields would be filled immediately with values of today's date and the date of a month before.
How could I do that? Any advice just to get me going?
You can add some code to populate the edits in the open() event of your window
with a given date that can be today(), you can compute a new date plus / minus a number of days with RelativeDate()
The following code just answers your question (though it could be better to use some editmask controls instead of singlelineedit as it would ease the handle of user's input):
date ld_now, ld_previousmonth
string ls_datefmt
ls_datefmt = "dd.mm.yy"
ld_now = today()
sle_1.text = string(ld_now, ls_datefmt)
ld_previousmonth= RelativeDate(ld_now, -30)
sle_2.text = string(ld_previousmonth, ls_datefmt)
It shows 09.07.13 and 09.06.13 at this time.
first of all you need to open your window. You can to this with put this code in your application open event (let suppose that your window is w_main):
open(w_main)
After that in put this code in your window's open event:
sle_date1.text = string(today())
sle_date2.text = string(RelativeDate(Today(), -30))
I think this solves your problem. Here is a little help for RelativeDate:
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.pocketbuilder_2.0.pkpsref/html/pkpsref/pkpsref662.htm
Best Regards
Gábor
Related
I text based .csv file with a semicolon separated data set which contains date values that look like this
22.07.2020
22.07.2020
17.07.2020
09.07.2020
30.06.2020
When I go to Format>number> I see the Google sheets has automatic set.
In this state I cannot use and formulas with this data.
I go to Format>number> and set this to date but formulas still do not see the actual date value and continue to display an error
Can someone share how I can quickly activate the values of this array so formulas will work against them?
I would be super thankful
Where the date are in column A, starting in cell A1, this formula will convert to DATE as a number, after which you apply formatting to Short Date style.
=ARRAYFORMULA(IF(A1:A="",,DATE(RIGHT(A1:A,4),MID(A1:A,4,2),LEFT(A1:A,2))))
Hopefully(!) the dates stay as text, otherwise Google Sheets would sometimes detect MM/dd/yyyy instead of dd/MM/yyyy, and you won't be able to distinguish between July 9th and September 7th in your example.
Solution #1
If your locale is for instance FR, you can then apply
=arrayformula(if(A1:A="";;value(A1:A)))
solution#2
you can try/adapt
function importCsvFromIdv1() {
var id = 'the id of the csv file';
var csv = DriveApp.getFileById(id).getBlob().getDataAsString();
var csvData = Utilities.parseCsv(csv);
csvData.forEach(function(row){
date = row[0]
row[0] = date.substring(6,10)+'-'+date.substring(3,5)+'-'+date.substring(0,2)
})
var f = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
f.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
}
First thanks to those that suggested a fix. I am not really a programmer and get cold sweats when I see suggesting of running scripts to solve simple problems. Sorry guys.
So the (non programmer) solution with the dates was to do a find/replace (CTRL + H) and replace all the (.)dots with (/)slashes, then to make sure the column is formatted as a date, then Google finally understands it as a date.
With the accounting values as well, I had to do the same find/replace to remove all the ' between thousands, then google woke up and understood them as numbers.
I am significantly underwhelmed by this from Google. They are getting too fat and lazy. They need some competition.
Im having a problem with a datepicker on vb6, but this jus happen on certain dates, for example 31/01/2017, but with another dates it works fine.
I appreciate the help
This almost certainly has to do with how you are setting the date in the control.
For instance if the control's value is ANY month that does not have 31 days then you will get that error. Trying to set the control to 31/02/2017 would cause an error 380.
There are two approaches you can take to fix this.
Reverse the order you set the date components.
dtFecha.Year = Year(fcsAux.Fields("xf3ch4"))
dtFecha.Month = Month(fcsAux.Fields("xf3ch4"))
dtFecha.Day = Day(fcsAux.Fields("xf3ch4"))
Set the Value property instead of the date components. dtFecha.Value = "31/02/2017"
dtFecha.Value = rcsAux.Fields("xf3ch4").Value
The first approach ensures the month is always appropriate for the day. The second approach sets the entire value at one shot and should be a valid date.
I am using Google Script to export some calendar events to a spreadsheet; the relevant portion of my script is below:
var details=[[mycal,events[i].getTitle(), events[i].getDescription(), events[i].getLocation(), events[i].getStartTime(), myformula_placeholder, ('')]];
var range=sheet.getRange(row,1,1,7);
range.setValues(details);
This code works but the "time" that is put into the spreadsheet is a real number of the form nnnnn.nn. On the spreadsheet itself the date looks great using the integer to the left of the decimal (eg 10/15/2017) but the decimals are part of the value and therefore are part of the spreadsheet value.
My script drops the data into a sheet in my workbook, and another sheet reads the rows of data with the above date types, looking for specific date info from the other sheet using the match function (for today()). That would work fine if I could get rid of the decimals.
How can I use what I have above (if I stray far from what I have found works I will be redoing hours of work) but adding just what is needed to only put into the output spreadsheet the whole number portion so I have a pure date that will be found nicely by my match function using today()?
I have been digging, but errors abound in trying to put it all together. "Parse" looked like a good hope, but it failed as the validation did not like parse used within getStartTime. Maybe I used it in the wrong manner.
Help would be appreciated greatly.
According to the CalendarApp documentation, getStartTime() generates a Date object. You should be able to extract the date and time separately from the date object:
var eventStart = events[i].getStartTime(); // Returns date object
var startDate = eventStart.toDateString(); // Returns date portion as a string
var startTime = eventStart.toTimeString(); // Returns time portion as a string
You could then write one or both of these to your spreadsheet. See the w3schools Javascript Date Reference for more information:
http://www.w3schools.com/jsref/jsref_obj_date.asp
If you If you want to specify the string format, you can try formatDate in the Utilities service:
https://developers.google.com/apps-script/reference/utilities/utilities#formatdatedate-timezone-format
You could just use the Math.floor() function
http://www.w3schools.com/jsref/jsref_floor.asp
which will round the real number to an integer. Your line would then read:
var details=[[mycal,events[i].getTitle(), events[i].getDescription(), events[i].getLocation(), Math.floor(events[i].getStartTime()), myformula_placeholder, ('')]];
I am trying to compare and check the date if it is today's date or not in a spesific program. I tried to use assertion method but when I use it the time will remain same if you try it next day. The main problem that I need to know when open a page from program It should be today's date and should be passed. if you know already anything about it please let me know also :)
Thanks yo!
Use System.DateTime.Now.ToString("yyyy-MM-dd") as one argument of the assertion. You may need to use a different format rather in the ...ToString() method. The exact format depends on how the date is shown on the screen.
This could be done using "StringAssert" to verify that your programs date string contains today's date string, while ignoring the time:
var programDateString = "7/25/2016 12:00:00"; //this is an example of your date retrieved from the application with time included
var todaysDate = System.DateTime.Today.ToShortDateString(); //short date string
StringAssert.Contains(programDateString, todaysDate);
I need to:
Set the form to "Not accepting responses" every weekday at 7:16 am
Then set the form to “Accepting responses” every weekday at 5:30 am
Clear all responses from the form and the form spreadsheet on Friday at 2:00 pm
I have no experience with writing scripts. This is for a teacher sign-in sheet for a public high school.
Any help is greatly appreciated!
Unfortunately, StackOverflow isn't here to write your code for you, so you won't receive an answer that you can copy/paste and get to work. The community will instead assist you with any specific roadblocks that you encounter with your code (If they can).
However, you'll be able to achieve this with the Form Service, specifically, the '.setAcceptingResponses()' method. You'll also need the Spreadsheet service with the '.clear()' method to empty the sheet.
You'll find the time triggers are the easiest way to set when the form becomes active and inactive again, however, you've mention very specific times that this needs to go offline and online again (7:16 am and 5:30 am, but only on weekdays, and 2PM to clear the sheet on Fridays), but Google Apps script time triggers can't be set down to the minute (Note the triggers explanation about the time being randomized).
An alternative would be to write a function that checks the time, have that function run every minute, and if the time = 2PM on a Friday then clear the sheet etc.
have you checked out formLimiter by New Visions Cloud Lab?
http://cloudlab.newvisions.org/add-ons/formlimiter
The description is:
formLimiter automatically sets Google Forms to stop accepting responses after a maximum number of responses, at a specific date and time, or when a spreadsheet cell contains a specified value.
Great for time-bound assignments, event registrations with limited seats, or other first-come, first-served signup scenarios.
I was able to write a short script and set a trigger, I named my form "Play"
Here is the script:
function limitDays() {
var form = FormApp.getActiveForm();
var lastDay = 21;
var currDate = new Date();
var dayOfMonth = currDate.getDate();
if (dayOfMonth > lastDay) {
form.setAcceptingResponses(false);
} else {
form.setAcceptingResponses(true);
}
}