Populating a array of date tuples Scala
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2021 11:32 PM
Hi Friends
i am trying to pass a list of date ranges needs to be in the below format.
val predicates =
Array(“2021-05-16” → “2021-05-17”,“2021-05-18” → “2021-05-19”,“2021-05-20” → “2021-05-21”)I am then using map to create a range of conditions that will be passed to the jdbc method.
val predicates =
Array(“2021-05-16” → “2021-05-17”,“2021-05-18” → “2021-05-19”,“2021-05-20” → “2021-05-21”)…map { case (start, end) =>s"cast(NEW_DT as date) >= date ‘$start’ AND cast(NEW_DT as date) <= date ‘$end’"The process will need to run daily and i need to dynamically populate these values as i cannot use the hard coded way.
Need help in how i can return these values from a method with incrementing start_date and end_date tuples that can generate like above.I had a mere idea like below but as i am new to scala not able to figure out. Please help
def predicateRange( start_date: String,
end_date: String): Array[(String,String)]= {// iterate over the date values and add + 1 to both start and end and return the tuple}
Labels:
- Labels:
-
Scala