Getting day number in the week in a stored procedure - mysql

How can I get the number of a day in a week fro example:
2009-10-21 would be 4 assuming that:
Sun - 1
Mon - 2
Tue - 3
Wed - 4
Thu - 5
Fri - 6
Sat - 7
I am using MySql Server 5.0.37

SELECTDAYOFWEEK('2009-10-13')

Related

Set nominal time to run the oozie coordinator daily in HUE

I am trying to set SLA for my oozie coordinator but nominal_time always stays on the day when i submitted the coordinator.
SLA Details:
Nominal Time - Thu Dec 05 15:45:00 UTC 2019
Actual Start Time - Sat Dec 07 07:45:00 UTC 2019
Expected End Time - Thu Dec 05 16:05:00 UTC 2019
Expected Duration (in mins) - 45
Actual Duration (in mins) - -1
How do i increase nominal_time by a day to match it with actual_time ?
I could fix it by passing ${coord:nominalTime()} in nominal_time.

MySQL select multiple date range

I have a table with 2 dates: startDate and EndDate
I pass to my query 2 dates and I want to check if in this date range the offer are available.
I have an offer that is valid From 1 may 2019 to 30 may 2019.
When I search in offers, I want to show this only if the date range that I pass is included in the date range of the offer.
OFFER From 1 may 2019 to 30 may 2019
Value pass: 01 jan 2019 to 4 jan 2019 NO SHOW
Value pass: 28 april 2019 to 2 may 2019 NO SHOW
Value pass: 10 may 2019 to 12 may 2019 ONLY SHOW IN THIS CASE
Value pass: 29 may 2019 to 2 june 2019 NO SHOW
Value pass: 10 nov 2019 to 12 now 2019 NO SHOW
How can I do this?
This will work for MySQL.
date_from < '2019-10-05' AND date_to > '2019-10-12'

MySQL Custom WEEK() Mode

I am trying to create a weekly report (including grouping by WEEK(date)) where weeks start on Monday. However, Week 1 is always the first week any day of a new year occurs. For example if Jan 1st is a Friday, that is week one.
This doesn't seem to be consistent with MySQL mode options for WEEK():
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_week
Based on the available options it only works if the week has 4 or more days (options 1 and 3) or the Monday is in the new year (options 5 and 7). Neither of these account for example week 1 of 2016:
Wk Mon Tue Wed Thu Fri Sat Sun
No.
1 28 29 30 31 1 2 3
Is there any way to order/number the week numbers in MySQL based on this custom week mode requirement?

SSRS Report with Business days as Expression

I have an SSRS report with the following header,
Date 28-Mar 27-Mar 25-Mar 24-Mar 23-Mar 22-Mar 21-Mar 20-Mar
Day Fri Thu Wed Tue Mon Sun Sat Fri
Pending 1 2 3 4 5 5 5 6
I able to generate Date and Day rows using expression with current date.
(e.g. = Left(WeekDayName(WeekDay(DateAdd("d",-1,Now()))),3))
But Pending Days row should display age in days with same age number for Mon, Sun and Sat since Sun and Sat are off days.
Is it possible to generate with expression?
Got it Guys,
We just need to make sum of no of 'mon', 'tus'..'fir' in the date range.
=DATEDIFF("ww",DateAdd("d",-1,Now()),Now(), vbMonday)
+
DATEDIFF("ww",DateAdd("d",-1,Now()),Now(), vbTuesday)
etc.
:)

Sql Server Query not getting desire Result

I want show record month wise and date wise. My query is this but I am not getting how I can achieve this.
Query is
select
iWorkItemId
, convert(varchar(20),Progress.dtProgressDate,106) as dtProgressDate
, vsDescription
, WPD.rWeightage
, Progress.ProgressPerc as ProgressPerc
, Convert(decimal(6,2)
, ((WPD.rWeightage * Progress.ProgressPerc)/100)) as TotalProgress
from tblPkgWorkItems WPD
join tblPkgWorkItemsProgress Progress on WPD.iWorkItemId = Progress.iWorkItemsId
where iPackage='7'
group by iWorkItemId, dtProgressDate,vsDescription,rWeightage,ProgressPerc,progressmonth
order by progressmonth ASC,dtProgressDate ASC , iWorkItemId ASC
Column name : (1) progressmonth (Store Month Name)
(2) dtProgressDate (Store complete date)
Example :
In our table we are storing the records like in this manner:
30 Apr 2013
31 Aug 2013
28 Feb 2013
30 Jan 2013
Then I want to show records like this
30 Jan 2014
if some record is inserted in 15 jan 2014 then After 30 jan 2014 then 15 jan 2014 record will show.
28 Feb 2014
30 Apr 2014
30 Aug 2014
Means firstly Jan records will come then Feb record then March records.
Means all records will come month by order then sort by date wise .
My data is being returned like this:
iWorkItemId dtProgressDate progressmonth rWeightage
320 30 Apr 2014 Apr 2
321 20 Apr 2014 Apr 3
320 10 Feb 2014 Feb 4
321 9 Jan 2014 Jan 7
I want record should come first 9 jan 2014 then 10 Feb 2014 (Means Order by Month) then after it 30 April 2014, then 20 april 2014 (Then Sot by Date).
iWorkItemId will repeat win every month.
For my problem is I want to show
Firstly Jan records then Feb records , then March records
And whenever Jan month is coming then All Date which is belong to jan month that will come under JAN month.
Firstly Higher date of JAN month (Means ) 31 Jan 2014, 30 jan 2014, 29 jan 2014, 28 feb 2014, then 27 feb 2014.
Means first records fetch month wise then on particular month that records sort by datewise