Reporting Services Expression for Week of Year - asp.net

I have a Report that I send a parameter to as 'WeekStart'. This is based on a selection a user makes on a datepicker.
I'm using the following to extract the week of the year:
=DatePart("ww", Parameters!WeekStart.Value)
The problem I'm having is that when I pick the day 03/01/2012 (dd/MM/yyyy format), the week of the year is returned as 9, which would technically be true had the date been 03/01/2012 with a dateformat of MM/dd/yyyy.
I've tried using CDate, FormatDateString etc but nothing seems to be working. I either get #Error or it returns as the 9th week of the year.
Any suggestions?

What you can do is this:
use YourDatabase
go
set dateformat dmy
go
That will set the date format for your database, and that should get your DATEPART function working as expected.
SET DATEFORMAT (MSDN)

Related

robotoframework selenium calculate yesterday date in python script

I have
${date}= Get Current Date result_format=%Y-%m-%d
but I need yesterday date... how can I calculate -1day? I try format %d-1 but not work
The DateTime library has an Add Time To Date keyword which should do what you need:
${CurrentDate}= Get Current Date result_format=%Y-%m-%d
${newdatetime} = Add Time To Date ${CurrentDate} -1 days

How to convert the UTC date into local date in Moment.js?

I have a date in this format "2020-12-16T02:48:00" that came from the server. How can I convert this into local date and time? I tried some code but couldn't succeed.
Below is the attempt that I had made in angular after receiving date from the server.
response.data.map(date=>{
var centralDate = moment( date).zone("-06:00");
date = moment(centralDate).local().format('YYYY-MM-DD hh:mm:ss');
})
If indeed the value is in UTC (as per the title of your question), and it looks like "2020-12-16T02:48:00", and you want to convert it to local time, then you should do the following:
moment.utc(date).local().format('YYYY-MM-DD HH:mm:ss');
That does the following:
Parses the input in terms of UTC
Converts it to local time
Formats it as a string in the given format
Note also that you had hh in your original format. That is for hours in a 12-hour time format and thus you shouldn't use it without also using either A or a to indicate AM/PM or am/pm. Otherwise HH is for hours in a 24-hour time format.
If your issue is that the timezone doesn't change you can resolve using utcOffset (https://momentjscom.readthedocs.io/en/latest/moment/03-manipulating/09-utc-offset/) in this way:
response.data.map(date=>{
date = moment( date).utcOffset(-360);
})
Where 360 is the conversion fo the hours in minutes
var d= new Date();
d = new Date(d+ "Z")
I am not an expert in angular but I guess the trouble in your date is the word “T”. May be using string removal function you can remove the word “T” and then it becomes a proper date time value?

How to subtract a date from another date using Robot Framework?

i'm using Robot Framework Keyword Subtract Date From Date to test that a date is between 2 dates(For example 11/06/2020 is between 07/06/2020 and 20/06/2020), but i'm getting an error in my log file ValueError: Invalid timestamp. The date is a String extracted from a Span Text and i convert it to date This is my code :
${date}= Get Current Date result_format=datetime
${postdate}= Get Text xpath://app-post[1]//div[1]//div[1]//div[1]//div[2]//div[1]//div[2]//div[1]//div[2]//span[2]
${postdate}= Convert Date ${postdate} date_format=%d/%m/%y
${date}= Convert Date ${date} result_format=%d/%m/%y
${temp} = Subtract Date From Date ${postdate} ${date}
Should Be True ${temp}>=0
The problem is you don't follow the allowed format for the keyword Subtract Date From Date mentioned here: https://robotframework.org/robotframework/latest/libraries/DateTime.html#Date%20formats
%y will give you 20, but that obviously is not enough. If I change it to %Y, it will give me 2020 for the current year, and the keyword Subtract Date From Date doesn't complain anymore about invalid timestamp. You'd also need to change it to something like date_format=%Y/%m/%d, that is to change the order of %Y, %m, and %d.
EDIT:
I can now see you're also using date_format as well as result_format with Convert Date. That's another bug in your code, you need to use result_format with both.
EDIT 2:
The full working example:
(And you're not using BuiltIn library here, these datetime keywords are from DateTime library)
The below script worked (Used the static PAST_DATE to check the sample run ):
${date}= Set Variable 21
${month}= Set Variable 12
${year}= Set Variable 2019
${PAST_DATE}= BuiltIn.Catenate SEPARATOR=/ ${year} ${month} ${date}
Log ${PAST_DATE}
${CURRENT_DATE}= Get Current Date result_format=%Y/%m/%d
Log ${CURRENT_DATE}
${DIFFERNCE_IN_DAYS}= Subtract Date from Date ${CURRENT_DATE} ${PAST_DATE} verbose
Log ${DIFFERNCE_IN_DAYS}
#{total_days}= Split String ${DIFFERNCE_IN_DAYS}
${final_days}= Set Variable ${total_days[0]}
Log ${final_days}
Should be true ${final_days} >= 0

Hive Date Time Week

I want to extract date of each week's Monday for each week in hive. I can do that with Presto by using date_trunc function however in hive I don't have a direct function which can extract Monday Date.
My Presto code is similar to this,
select
a.abc_id
,cast(date_trunc('week', from_unixtime(p.xyz_date)) as timestamp) as xyz_week
from PQR
The output is for each id I will get Week but in the form of date format which is nothing but the date of every Monday of past weeks (user can specify how many week's he wants to assess).
I searched all the date functions of hive but is there a function which can replace date_trunc?
what you need is the date function : next_day(string start_date, string day_of_week)
For example: next_day('2018-02-22', 'Mon') = '2018-02-26''
My hive version is 1.4.

C# format of date issue

My problem: I need to get date format as "mm/dd/yyyy"
Scenario:
I have declared DateBirth as nullable DateTime.
The value I get when I use:
AdvancedObj.DateBirth .Value.ToString()
is: "13/03/2013 00:00:00"
The value I get when I use
AdvancedObj.DateBirth .Value.ToString(CultureInfo.InvariantCulture)
is :"03/13/2013 00:00:00"//This is roughly correct but, I do not need 00:00:00
I have tried this as well, but the format is correct and value is incorrect.
AdvancedObj.DateBirth.Value.ToString("dd/mm/yyyy",CultureInfo.GetCultureInfo("en-Us"))
**"13/00/2013"**
Can anybody point me, what am I missing?
Use the right format string for months - it is MM. mm is for minutes:
AdvancedObj.DateBirth.Value.ToString("MM/dd/yyyy",CultureInfo.InvariantCulture)
Also, order them correctly as above - if you want months before days, use MM/dd/yyyy, if the other way around, dd/MM/yyyy.
I suggest you take a good long read of Custom Date and Time Format Strings on MSDN.
Month are 'M'. 'm' is for minutes.
"dd/MM/yyyy"

Resources