You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spark.apache.org by "farman.bsse1855" <fa...@zigron.com> on 2016/09/07 11:27:20 UTC

How to get 2 years prior date from currentdate using Spark Sql

I need to derive 2 years prior date of current date using a query in Spark
Sql. For ex : today's date is 2016-09-07. I need to get the date exactly 2
years before this date in the above format (YYYY-MM-DD).

Please let me know if there are multiple approaches and which one would be
better.

Thanks



--
View this message in context: http://apache-spark-developers-list.1001551.n3.nabble.com/How-to-get-2-years-prior-date-from-currentdate-using-Spark-Sql-tp18875.html
Sent from the Apache Spark Developers List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe e-mail: dev-unsubscribe@spark.apache.org


Re: How to get 2 years prior date from currentdate using Spark Sql

Posted by Herman van Hövell tot Westerflier <hv...@databricks.com>.
This is more a @use question.

You can write the following in sql: select date '2016-09-07' - interval 2
years

HTH

On Wed, Sep 7, 2016 at 3:14 PM, Yong Zhang <ja...@hotmail.com> wrote:

> sorry, should be date_sub
>
>
> https://issues.apache.org/jira/browse/SPARK-8187
> [SPARK-8187] date/time function: date_sub - ASF JIRA
> <https://issues.apache.org/jira/browse/SPARK-8187>
> issues.apache.org
> Apache Spark added a comment - 12/Jun/15 06:56 User 'adrian-wang' has
> created a pull request for this issue: https://github.com/apache/
> spark/pull/6782
>
>
>
> ------------------------------
> *From:* Yong Zhang <ja...@hotmail.com>
> *Sent:* Wednesday, September 7, 2016 9:13 AM
> *To:* farman.bsse1855; dev@spark.apache.org
> *Subject:* Re: How to get 2 years prior date from currentdate using Spark
> Sql
>
>
> https://issues.apache.org/jira/browse/SPARK-8185
> [SPARK-8185] date/time function: datediff - ASF JIRA
> <https://issues.apache.org/jira/browse/SPARK-8185>
> issues.apache.org
> Spark; SPARK-8159 Improve expression function coverage (Spark 1.5)
> SPARK-8185; date/time function: datediff
>
>
>
> ------------------------------
> *From:* farman.bsse1855 <fa...@zigron.com>
> *Sent:* Wednesday, September 7, 2016 7:27 AM
> *To:* dev@spark.apache.org
> *Subject:* How to get 2 years prior date from currentdate using Spark Sql
>
> I need to derive 2 years prior date of current date using a query in Spark
> Sql. For ex : today's date is 2016-09-07. I need to get the date exactly 2
> years before this date in the above format (YYYY-MM-DD).
>
> Please let me know if there are multiple approaches and which one would be
> better.
>
> Thanks
>
>
>
> --
> View this message in context: http://apache-spark-
> developers-list.1001551.n3.nabble.com/How-to-get-2-years-
> prior-date-from-currentdate-using-Spark-Sql-tp18875.html
> Apache Spark Developers List - How to get 2 years prior date from
> currentdate using Spark Sql
> <http://apache-spark-developers-list.1001551.n3.nabble.com/How-to-get-2-years-prior-date-from-currentdate-using-Spark-Sql-tp18875.html>
> apache-spark-developers-list.1001551.n3.nabble.com
> How to get 2 years prior date from currentdate using Spark Sql. I need to
> derive 2 years prior date of current date using a query in Spark Sql. For
> ex : today's date is 2016-09-07. I need to get the...
>
> Sent from the Apache Spark Developers List mailing list archive at
> Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe e-mail: dev-unsubscribe@spark.apache.org
>
>

Re: How to get 2 years prior date from currentdate using Spark Sql

Posted by Yong Zhang <ja...@hotmail.com>.
sorry, should be date_sub


https://issues.apache.org/jira/browse/SPARK-8187

[SPARK-8187] date/time function: date_sub - ASF JIRA<https://issues.apache.org/jira/browse/SPARK-8187>
issues.apache.org
Apache Spark added a comment - 12/Jun/15 06:56 User 'adrian-wang' has created a pull request for this issue: https://github.com/apache/spark/pull/6782




________________________________
From: Yong Zhang <ja...@hotmail.com>
Sent: Wednesday, September 7, 2016 9:13 AM
To: farman.bsse1855; dev@spark.apache.org
Subject: Re: How to get 2 years prior date from currentdate using Spark Sql


https://issues.apache.org/jira/browse/SPARK-8185

[SPARK-8185] date/time function: datediff - ASF JIRA<https://issues.apache.org/jira/browse/SPARK-8185>
issues.apache.org
Spark; SPARK-8159 Improve expression function coverage (Spark 1.5) SPARK-8185; date/time function: datediff




________________________________
From: farman.bsse1855 <fa...@zigron.com>
Sent: Wednesday, September 7, 2016 7:27 AM
To: dev@spark.apache.org
Subject: How to get 2 years prior date from currentdate using Spark Sql

I need to derive 2 years prior date of current date using a query in Spark
Sql. For ex : today's date is 2016-09-07. I need to get the date exactly 2
years before this date in the above format (YYYY-MM-DD).

Please let me know if there are multiple approaches and which one would be
better.

Thanks



--
View this message in context: http://apache-spark-developers-list.1001551.n3.nabble.com/How-to-get-2-years-prior-date-from-currentdate-using-Spark-Sql-tp18875.html
Apache Spark Developers List - How to get 2 years prior date from currentdate using Spark Sql<http://apache-spark-developers-list.1001551.n3.nabble.com/How-to-get-2-years-prior-date-from-currentdate-using-Spark-Sql-tp18875.html>
apache-spark-developers-list.1001551.n3.nabble.com
How to get 2 years prior date from currentdate using Spark Sql. I need to derive 2 years prior date of current date using a query in Spark Sql. For ex : today's date is 2016-09-07. I need to get the...


Sent from the Apache Spark Developers List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe e-mail: dev-unsubscribe@spark.apache.org


Re: How to get 2 years prior date from currentdate using Spark Sql

Posted by Yong Zhang <ja...@hotmail.com>.
https://issues.apache.org/jira/browse/SPARK-8185

[SPARK-8185] date/time function: datediff - ASF JIRA<https://issues.apache.org/jira/browse/SPARK-8185>
issues.apache.org
Spark; SPARK-8159 Improve expression function coverage (Spark 1.5) SPARK-8185; date/time function: datediff




________________________________
From: farman.bsse1855 <fa...@zigron.com>
Sent: Wednesday, September 7, 2016 7:27 AM
To: dev@spark.apache.org
Subject: How to get 2 years prior date from currentdate using Spark Sql

I need to derive 2 years prior date of current date using a query in Spark
Sql. For ex : today's date is 2016-09-07. I need to get the date exactly 2
years before this date in the above format (YYYY-MM-DD).

Please let me know if there are multiple approaches and which one would be
better.

Thanks



--
View this message in context: http://apache-spark-developers-list.1001551.n3.nabble.com/How-to-get-2-years-prior-date-from-currentdate-using-Spark-Sql-tp18875.html
Apache Spark Developers List - How to get 2 years prior date from currentdate using Spark Sql<http://apache-spark-developers-list.1001551.n3.nabble.com/How-to-get-2-years-prior-date-from-currentdate-using-Spark-Sql-tp18875.html>
apache-spark-developers-list.1001551.n3.nabble.com
How to get 2 years prior date from currentdate using Spark Sql. I need to derive 2 years prior date of current date using a query in Spark Sql. For ex : today's date is 2016-09-07. I need to get the...


Sent from the Apache Spark Developers List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe e-mail: dev-unsubscribe@spark.apache.org