Get current 1 year from_now as number - ruby

How I can get the next year from now?
1.year.from_now
I need to get only 2019 as a result from the above code.

Use Time.now.next_year (activesupport needed) and if you want only year then go with Time.now.year + 1

Other option
require 'date'
Date.today.next_year.year

1.year.from_now.year
does the job.

Any expression returns now + .next_year + .year
Time.now.next_year.year
Date.current.next_year.year
DateTime.current.next_year.year
etc. and all others solutions proposed.
I hope it useful for you. :)

Use this code: DateTime.now.year + 1

Related

Is there a Contains function in SAS Hive (Hadoop)?

I'm needing help again
Is there an equivalent to the Contains function in SAS Hadoop (explicit SQL Pass through) ?
E.g. an alternative version to:
WHEN a.DESCRIPTION NOT CONTAINS "XXX"
I attempted using:
When (array_contains(a.DESCRIPTION ,'XXX') = FALSE)
But that does not work.
Any help most welcome!
Thanks Kiran for suggesting the instr function.... looks like it does what I needed
So I used to get what I wanted:
When instr(a.DESCRIPTION, 'XXX') = 0 Then 1
Mayank.... Thanks for your suggestion, I'll investigate this function later on
You can probably use rlike(regular_expression).
WHERE some_col RLIKE '*abc*|*pqr*|*xyz*'
For negative results, put a NOT before RLIKE.
Let me know if this works.

JMeter: adding two numbers, one from function

I am trying to get the current time in milliseconds and to add to it 5 minutes... Tried:
${__time + 1000 * 60 * 5}
Tried many more variations, none of them worked..
Any ideas?
You could try this too.
${__groovy(System.currentTimeMillis()+5*60*1000,)}
Answering myself, sharing it with you...
The solution here is to use:
{__longSum(${__time}, 900000)}
Another alternative that would work also similar to the groovy solution is:
${__jexl2(${__time}+900000)}

MINUTE FROM NUMTODSINTERVAL( formatting

I don't see anything on the oracle docs saying how to change the formatting of the output of a numtodsinterval function so I was hoping you could help
EXTRACT(MINUTE FROM NUMTODSINTERVAL(TOTAL_HOURS, 'HOUR'))
I would like this to come out in a two digit format :'MM', now it works in converting 1.25 into 1:15 but if the time is 8.1333 it displays 8:8
thanks!
Hey sorry yes you're right, I had not given enough information, I did want to display it in typical time fashion HH:MM, and also you are right it does return a number, I did not have a to_char , adding it made this a simple problem to solve so thank you!

Doctrine 1 : older than 1 year

Can someone please tell me how to create a query to show something older than 1 year without using DATE_ADD because I guess this function is used just in doctrine2?
Something like Where (DateField > (GetDate() + 365)) should work.

What's the most efficient way get the first day of the current month?

With ruby I'm trying to get format a date as such: 2009-10-01
Where I take the current date (2009-10-26) and then change the day to "01".
I know of ways to do this, but was curious what the shortest way is, code wise, to pull this off.
If you don't mind including ActiveSupport in your application, you can simply do this:
require 'active_support'
date = Date.today.beginning_of_month
Time.parse("2009-10-26").strftime("%Y-%m-01")
require 'date'
now = Date.today
Date.new(now.year, now.month, 1)
Most efficient to get start and end date of current month
#date = DateTime.now
#date.beginning_of_month
#date.end_of_month
If you need the date object without ActiveSupport, you can go back to the last day of the last month and sum 1.
Date.today - Date.today.mday + 1
Like
Date.today.beginning_of_day
Date.today.end_of_day
And
Date.today.beginning_of_week
Date.today.end_of_week
There also is
Date.today.beginning_of_year
Date.today.end_of_year
This works...
Not terribly clever :/
require 'date'
Date.parse(Date.parse("2009-10-26").to_s[0,8] << "01")
require 'active_support/core_ext'
Date.today.beginning_of_month

Resources