Applescript Excel Date cell value not displaying correctly - applescript

When I use the following Applescript (which I found on StackOverflow :)), it works great except that the cell the script selects is a date but it does not display it correctly at the applescript. Perhaps this will help:
set searchRange to range ("D1:D100")
set foundRange to find searchRange what "string" with match case
set fRow to first row index of foundRange
set myData to value of range ("B" & fRow as text)
The value of the selected cell in column B is 4:14:00 AM but in AppleScript, it returns as 0.176388888889
How can I solve this?

That seems to be the way Excel stores the data internally. Try using string value instead of value. That worked for me.

Your question is answered, but just to add out of interest: Excel stores time as a decimal fraction, and the formatting makes it meaningful. So noon is 0.5, and in theory, 24:00:00 would be 1, but obviously time rolls round to 00:00:00 again. If you multiply your 04:14:00 by 86400 (the number of seconds in a day), it will reveal the time in seconds. So you can see how to do maths with time, and how Excel does maths in the background.
Dates are stored as integers, counting up from 01/01/1901 (1), where today's date is stored as 41601.
To see the stored value just change the cell format to 'general' (cmd+1, useful shortcut).

Related

Crestron SIMPL Text Entry Field Initializing

I am trying to program the system where you choose day of week and in a text field next to it you should be able to chose the time of the day in increment of 15 min + or -. Which of joins should I use for txt field and how to put default time in the field?
You would just need to use an initialised value for the default time and have it incremented +/- as needed. Text entry join numbers can be the same as text feedback joins but it's better to use different ones.

Google sheets time formatting won't work for me

I'm rather new to google sheets, and I'm trying to make a timesheet that will calculate hours and minutes automatically. The problem I'm facing is that the formula always returns a "#VALUE!"-error because "23:15 is a text and cannot be coerced to a number".
I've formatted the cells to time, but it won't recognize the input as hours and minutes. What am I doing wrong here?
It happened to me too, I discovered that you have to change the location:
File > Spreadsheet Setting > Locale > United Kingdom
you will see that now you can type your time correctly with the ":"
Try going to Format, Number, More Formats, More Date time formats.Select Hour Minute (13:30). Apply this format to all columns (or cells) involved in the calculation.
Here is a copy of my test spreadsheet. I can't get yours to work(?), but this does:
https://docs.google.com/spreadsheets/d/1Qg1JJU9MELesqllHFOhKFO-jxDf1fJMiIVznU1vNP0w/edit?usp=sharing
It is set to your country.

select rows with hour and not half hour

How to extract only rows with hour and not half hour i libreoffice
2014/06/15 19:30:00
2014/06/15 20:00:00
2014/06/15 20:30:00
=>
2014/06/15 20:00:00
It turned out that i could:
extract the time part using a =right(D1;8)
Do a =IF(MINUTE(D1)<>0,"",1)
Sort by the 1's and remove the empty cells.
But, there must be a better and more neat way.
Nicolai
As moggi pointed out, it depends on the way the time data is presented:
If your values are valid date/time values for LO Calc, you can just apply the MINUTE() function to the complete value to extract the minutes, and compare it with 0. "Valid date/time" means that, e.g. the date/time value 2014/06/15 19:30:00 is internally represented as double value 40343.8125. Displaying this as date/time is a matter of formatting. You can check this by manually entering the double value into a unformatted cell and change the formatting to a date value.
If your values are text values, you may use a regex to match full-hour time values with something like .*[:digit:]{2}:00:00$. You can use this regex in Menu Data -> Filters -> Standard Filter or Advanced Filter; don't forget to enable Regular Expressions under the filter's Options.

Xpages sorting date

I'm stuck with sorting and showing the correct date in Xpages.
It is saved in format "dd.MM.yyyy" and it's a string.
Now why it's a string and formated that way, is because my boss has special wishes. And when I want to sort it from the newest date to older it does something like this:
26.05.2015
24.06.2014
22.04.2015
21.04.2015
20.03.2014
It starts sorting by day.
Is there a way to make it sort it like it should?
I see that i can write a Computed value to Sort column in view column header for date. But i don't know how to even start.
Change the underlying Notes view to get your date column into right order.
Convert the date strings to real date values in views column formula. Assuming your field is called DateText then your formula would be
#Date(#ToNumber(#Right(DateText; 4));
#ToNumber(#Middle(DateText; 3; 2));
#ToNumber(#Left(DateText; 2)))
It would be easier to use just #ToTime(DateText) but this can fail depending on server's local settings. Your date string format would work for a server with German locale settings but not for US. That's why is my suggested solution "safer".
If the date time value doesn't solve your problem and you do not transform your date via #Text (as mentioned in the comments) then create another (hidden) column BEFORE your column that should be displayed. Make this a true date (from your item), sort it and unsort the column to display.
Otherwise use this formula in the newly created sorted column:
#Text(#Year(yourDate))+"-"+#Right("00"+#Text(#Month(yourDate));2)+"-"+#Right("00"+#Text(#Day(yourDate));2)

Duration format in google spreadsheet

I'm trying to apply a duration format to some cells in google spreadsheet. I would like to convert an integer number in a format: X days x hours x minutes.
I've tried with some formats like: d:h:mm but i found a problem when I apply the format. It always put one day less. When I write 1 in the cell the convert to 31:0:00. When I write 2 the cells changes to 1:00:00.
That is because the duration format is actually a date / time format (for comparing dates).
If you simply enter a number (1) google will interpret that as midnight (as times are stored as fractions of whole days) of the reference day number 1.
Reference day in Google Sheets is 31/12/1899 - IE the 31st day of the month. That is why your result returns days=31.
To achieve what you want you effectively want to add 1 to your values. so that 1 (+1) actually becomes "2 days since 31/12/1899 - ie 01/01/1900 - ie 1 day, and you could then use custom format for display, but this wont work when you have >31 days.
I think the best way is to simply concatenate the data you have with relavent parts like so (where A1 is a cell containg your data - 1,2,1.5 etc):
=int(A1)&" days "&int(MOD(A1,1)*24)&" hours " & mod(MOD(A1,1)*24,1)*60 & " minutes"

Resources