Actionscript 3 Date by number - actionscript-3

I want to get the date by a number that I send from my server but I can't get it working it always says 1-1-1970.
This is the code that i used
creationDate = new Date(Number(creationTime));
But now is my question wich value must the creationtime have so it has a working date.
I tryed the timestamp and many other numbers like 01042014 but it doesn't work.

When you create Date instance with one parameter this parameter must be the the number of milliseconds since January 1, 1970 0:00:000 GMT. If you want to create 'Date' instance based of known year, month, day you need to write next:
var millenium:Date = new Date(2000, 0, 1); // warning: days start from 1, but months start from 0

Related

SSRS expression for current month = 'Current'

First off I'm very new to SSRS and expressions are a steep learning curve.
I'm trying to write an expression to say if current month show text 'Current' else 'Past'. I've tried a few things like Month(Now()) = "Current" but can't get it to work.
Isn't it always the current month? You need to be comparing another date to the current month.
I think what you want is if a particular date field in your data is within the current month then show CURRENT, otherwise show PAST.
=IIF(FORMAT(Fields!END_DATE.Value, "MMyyyy") = FORMAT(TODAY, "MMyyyy"), "Current", "Past")
I use the FORMAT function to format the dates into month/year format - this eliminates the days so that it's just comparing the year and month.
The expression reads as
If the month/year of the END_DATE field is equal to the month/year of
the current day, then return the string CURRENT else return PAST.
https://learn.microsoft.com/en-us/sql/reporting-services/report-design/expression-examples-report-builder-and-ssrs?view=sql-server-2017

Retrieve Natural Time Intervals in MySQL for the client Time Zone

I have a PHP-MySQL API with Time Zone Support. My database is in UTC and all date time calculations are made in UTC time, just converting to local time when data is displayed to the user.
The problem is when trying to retrive data in a natural time interval for a user in a different time zone, for example weeks, months, years and so on. The DB column is type DateTime and store dates in UTC. If I need all rows grouped by month and just use the UTC date stored in the database I will get some wrong rows, if the Time Zone differences made some rows shift its month.
Example: row with value 2015-05-01 00:00:00 is in May in UTC, but should be in April for any user in a negative Time Zone.
So using UTC is not the solution here. I need first to convert those dates to client Time Zone.
Which aproach can I use to overcome this problem?
As an example this is view groups some data by week:
SELECT `individuals_id`,
Str_to_date(Concat(Yearweek(`sessions_date`, 5), ' Monday'), '%X%V %W') AS `sessions_date`,
`protocol_index`,
`zone_index`,
Avg(`asymmetry_dom`) AS `asymmetry_dom`,
Avg(`asymmetry_rl`) AS `asymmetry_rl`,
FROM `sessions_data_view`
GROUP BY `individuals_id`,
Yearweek(`sessions_date`, 5),
`protocol_index`,
`zone_index`
ORDER BY `individuals_id`,
Yearweek(`sessions_date`, 5),
`protocol_index`,
`zone_index`
The problem is that Yearweek() should have different output for a row depending on the user time zone. It is not posible to use the column sessions_date in UTC if want to give consistent result to the user.
Rigth now I do not know the user Time Zone, but this should not be a limitation, since the app is in its desing phase and anything can be changed.
The API is a PHP application getting HTTP requests. It talks to a PHP Database class that wraps all queries to the MariaDB database. All response from the aPI is given as JSON, dates formated as UTC strings. The data is shown via a web application. DateTime Javascript objects are responsible to convert the responses from the API to correct dates for the client time zone.
Firstly, the only reliable way you have of getting the client's timezone is through javascript, assuming their computer's time-settings are correct.
Solution One - Javascript to PHP
I suggest collecting the users timezone with the following javascript:
var timeZone = new Date().getTimezoneOffset();
You will need to store this value in the database. You then format the UTC time with PHP code similar to this:
$date = new DateTime();
$timezone = new DateTimeZone('Australia/Sydney');
$date->setTimezone($timezone);
$formatted_date = $date->format('Y-m-d H:i:s');
Solution Two - PHP to Javascript
You convert a UTC string into a unix timestamp with the following:
$time = strtotime($utc);
You then return that to the browser, and have javascript format it like this:
var date = new Date(timestamp * 1000),
datevalues = [
date.getFullYear(),
date.getMonth()+1,
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds(),
];
Good luck!
edit: For converting MySQL for use with queries, use CONVERT_TZ, the format being:
CONVERT_TZ('date/time field','starting timezone','ending timezone')
For example:
select *, DATE_FORMAT(CONVERT_TZ(str_to_date(timestamp),'UTC','US/Eastern'), '%m/%d/%y %h:%i %p') as 'Date - Eastern' FROM table`

Convert Date to a number in mysql (Like how a date converts in Excel)

What is the correct function to use when i want to convert a date to a number. Like when you enter a date in excel for example (now()) and then it will show the date but when you click on the number format it will show you a number.
I tried to use Unix timestamp but its not exactly the output i was looking for.
The date i entered is today's date
=now()
and the output i was hoping to get is
42146
what's the correct function to get this result in mysql?
Thank you
Microsoft Excel bases date serial numbers from Jan 1, 1904 or from Jan 1, 1900 (depends on the setting in the workbook.)
To generate a date "serial number" similar to what Excel uses, just calculate the number of days between NOW() (or whatever date you want to convert), and the base date. For example:
SELECT DATEDIFF(NOW(),'1900-01-01') AS excel_serial_date_1900
(You might need to add 1 or subtract 1 to get the exact same value that Excel uses, I've not tested that.) If your Excel workbook is using the 1904 based serial date, use '1904-01-01' as the base date in the expression.
Note: the DATEDIFF function returns integer number of days, operates only on the "date" portion, and doesn't include any fraction of a day.
Reference: https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_datediff

how to convert json date to c# in Windows phone 8

I have to convert the json date to c# datetime format
date is 3190549620000
and it orginal date format is 24jan2014 1:17pm
how can i convert this , meanwhile i followed this blog but it not worked
First, 3190549620000 is very big, causing an overflow when using the method you linked to.
3190549620 (divided by 1000, meaning the original is in milli seconds ) works better.
Secondly, if I use the method you link to to revert to a unix timestamp, I get 1390565820.
Compare
1390565820
3190549620
If I reverse the 31 in your example to 13, I get the correct date, but incorrect time. Can you verify and confirm that your input starts with 31 and not 13?
The date issue is a simple one: it seems to be 5:30 difference. What timezone are you in? My guess would be IST, so that is simply a timezone offset issue :)
It seems that your timestamp () is in UTC.
Change the code from your link to:
private static DateTime ConvertFromUnixTimestamp(double timestamp)
{
var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
return origin.AddSeconds(timestamp / 1000).ToLocalTime();
}
If I use 1390549620000 instead of your 3190549620000 as input, I get your desired result.
First you need to know what is represented by that integer. Normally in a lot of services EPOCH dates are used. These EPOCH number are seconds since 1/1/1970 0:0:0, the first date in Unix. But maybe the service you are consuming is returning you ticks, or another format of date. Can you take a look at the docs??

Past 5 week calculation in WEBI (BO 4.0)?

I am facing issue in calculating past 5 week data based on current date (excluding currrent week)
For e.g:
Suppose we are in 40th week of this year, I need to get the sum of all the transactions for the previous 5 weeks (39, 38, 37, 36 & 35).
Currently calculating based on the calendar day but as Calendar day is giving the granular level of data, inorder to increase the performance I need to use the calendar week (sample data like (2012/40).
Is there a way to do this?
I'd construct a flag field (either in the back-end or in the universe) using datediff (in SQL Server terms).
Failing that, you could construct a variable in Web Intelligence using the Week function.
Pseudo-code but something like:
=IF(Transaction_Date < Week(CurrentDate()) AND Transaction_Date >= (Week(CurrentDate())-5); "TRUE"; "FALSE")