How to set default parameter as 7 days ago to different date format on ssrs - date

I have default parameter and this parameter shows me 7 days ago with the expression below:
=DateAdd("d",-7,CDate(Format(Today(), "MM/dd/yyyy")))
But my report just running without error while the customer using "MM/dd/yyyy" time format.
Is there a way to use this parameter ALSO with "dd/MM/yyyy" format?
I would like to set a parameter to show 7 days ago but ı would like to use this parameter with both time format.
Thanks

Don't use the Format. Just put =DateAdd("d",-7,Today()). It will automatically take the Format according to System's format.

Firstly, the format part of your expression is redundant and misleading - don't use it
=DateAdd("d",-7,Today())
Secondly, you don't have any choice of how SSRS displays it's datepickers. It shows american format only (M/d/Y)

A date is a value and values do not have a format. A date is displayed and has to be entered in a format that depends on the language settings of your browser. Using a date picker, you even don't have to care about the input format. So, just use an expression that calculates the desired value:
=Today.AddDays(-7)

Related

NSDataDetection for Dates in Images with different Formats dependent of Locale?

I would like to convert a Date on an image to a Date type in Swift to store that data. I thought that I could use NSDataDetector for doing this, because I don't know the exact format which will occur on the image.
I had for example this Date: 01.08.2022 with the format: dd.mm.yyyy but if I use the NSDataDetector it was interpreted with the format mm.dd.yyyy
Is it possible to change that behavior so that the usual order of the numbers for the days and months for the region is used for interpretation?
Thanks for an answer

How do I build an an expression using ADF expression language to dynamically generate date in yyyymmdd format for a speciific time zone?

I want to do something relatively straightforward please help I'm stuck
Given today's date is 02 May, 2021 in my current timezone (Pacific Standard Time), build the string 20210502 (yyyymmdd format) dynamically.
What is the simplest way to do this in ADF? I tried following but returns error invalid expression:
#substring(formatString(getutcdate()),0,8)
I'm also not sure how to make it flexible so I can enter a different timezone if I want like Pacific Standard Time.
You can create a timezone variable and pass that value to convertFromUtc or convertTimeZone function. And you can choose format as you need. Here is the format specifiers list.
You can follow this:
expression:#replace(split(convertFromUtc(utcnow(),variables('timezone'),'u'),' ')[0],'-','')
Output:

$Date.Format on Silverstripe 4 Template

I have a date in the database with this format "YY-mm-dd". On the template I want it in this format: dd.mm.YY
Usually it would work with $date.Format('d.m.Y')
But not in Silverstripe 4. It converts from 2018-05-08 to 8.0.2018. Only the year is correct. Was there a change. I didn't find anything in the Documentation
Date formats in SS4 were changed from PHP date formatting to CLDR date formatting (changelog link):
Changed Format() method to use CLDR format strings, rather than PHP format string. E.g. d/m/Y H:i:s (php format) should be replaced with to dd/MM/y HH:mm:ss (CLDR format).
You can use this to achieve what you want:
$Date.Format('dd.MM.y')
The guide mentioned in the previous answer regarding date formatting has moved. The new location for CLDR date formatting as used by Silverstripe 4 can be found here:
https://unicode-org.github.io/icu/userguide/format_parse/datetime/#date-field-symbol-table

MakeInstant from Text doesn't work - Argument to MakeInstant should have a different form

I've been playing with MIT AppInventor and attempted to calculate a duration between two dates.
I take date values from two text fields. Clock.MakeInstant says it's only able to accept dates in MM/DD/YYYY format so I was careful to do that. Still, when I attempt to feed them into MakeInstant it always pops the same message about being able to only accept MM/DD/YYYY hh:mm:ss or MM/DD/YYYY or hh:mm. I printed entered text values before passing them to MakeInstant to confirm that they are not somehow corrupted and they are fine -- each just a date in MM/DD/YYYY format.
I have no idea what else to try. As far as I can tell I followed the instructions to the letter. Any examples on how to pass a date as text to Clock.MakeInstant?
see this screenshot source: https://groups.google.com/d/topic/app-inventor-shared-utilities-repository/3bA4wczU9pU/discussion
Taifun

Bug in Zend_Date (back in time)

I have a very strange problem, Zend_Date is converting my timestamp to a year earlier.
In my action:
// Timestamp
$intTime = 1293922800;
// Zend_Date object
$objZendDate = new Zend_Date($intTime);
// Get date
echo date('Y-m-d',$intTime).'<br>';
echo $objZendDate->get('YYYY-MM-dd');
This outputs:
2011-01-02
2010-01-02
Can anyone tell me what i'm doing wrong?
From the ZF issue tracker it seems this is a known issue:
Recently a lot of ZF users are filing a bug that Zend_Date returns the wrong year, 2009 instead of 2008. This is however expected behaviour, and NOT A BUG!
From the FAQ:
When using own formats in your code you could come to a situation where you get for example 29.12.2009, but you expected to get 29.12.2008.
There is one year difference: 2009 instead of 2008. You should use the lower cased year constant. See this example:
$date->toString('dd.MM.yyyy');
instead of
$date->toString('dd.MM.YYYY');
From the manual
Note that the default ISO format differs from PHP's format which can be irritating if you have not used in previous. Especially the format specifiers for Year and Minute are often not used in the intended way.
For year there are two specifiers available which are often mistaken. The Y specifier for the ISO year and the y specifier for the real year. The difference is small but significant. Y calculates the ISO year, which is often used for calendar formats. See for example the 31. December 2007. The real year is 2007, but it is the first day of the first week in the week 1 of the year 2008. So, if you are using 'dd.MM.yyyy' you will get '31.December.2007' but if you use 'dd.MM.YYYY' you will get '31.December.2008'. As you see this is no bug but a expected behaviour depending on the used specifiers.
For minute the difference is not so big. ISO uses the specifier m for the minute, unlike PHP which uses i. So if you are getting no minute in your format check if you have used the right specifier.
To add to zwip's answer, what happens behind the scenes is that your date format YYYY-MM-dd is actually translated into o\-m\-d, which is then passed to PHP's date() function internally with the timestamp you provided.
Like mentioned in the other answer, and in the documentation for the o format on the date format page, the calculation of the year based on the ISO week can sometimes result in the year being one different to the value that you expect.