logo
down
shadow

Find month and year inside string


Find month and year inside string

By : ahmed khalaya
Date : November 20 2020, 03:01 PM
Hope that helps A solution using dplyr, rebus, and stringr. Notice that it assumes only 1 matching month and year per row.
code :
library(dplyr)
library(rebus)
library(stringr)

df2 <- df %>%
  mutate(STRINGS = as.character(STRINGS)) %>%
  mutate(MONTH = str_extract(STRINGS, or1(months)),
         YEAR = str_extract(STRINGS, or1(years)))
df2
                 STRINGS    MONTH YEAR
1 January 2017 Blah Blah  January 2017
2     February Blah Blah February <NA>
3         2016 Yeah Yeah     <NA> 2016
4            March Bleck    March <NA>
5                  Stuff     <NA> <NA>


Share : facebook icon twitter icon
Easiest way to show month number and year after certain month year upto current month and year

Easiest way to show month number and year after certain month year upto current month and year


By : Bryant caveant Cueva
Date : March 29 2020, 07:55 AM
wish helps you you can use strtotime and date to do this.
code :
$start=strtotime('2015-03-01');
while ($start <= time()){
    echo date('m/Y',$start) . "\n";
    $start=strtotime('+1 month', $start);
}
03/2015
04/2015
05/2015
06/2015
07/2015
08/2015
09/2015
10/2015
11/2015
12/2015
01/2016
Find records where year-month is between the specified year-month pairs

Find records where year-month is between the specified year-month pairs


By : Ed Metzler
Date : March 29 2020, 07:55 AM
This might help you My data looks like this: , Here is one solution:
code :
-- The (Y1, M1) pair must be less than or equal to (Y2, M2)

SET @Y1 = 2014;
SET @M1 = 11;
SET @Y2 = 2016;
SET @M2 = 1;

SELECT *
FROM traffic
WHERE
    toll_id = 14 
    AND @Y1 <= `year` AND `year` <= @Y2 
    AND NOT (
        (@Y1 = `year` AND `month` < @M1) OR
        (@Y2 = `year` AND `month` > @M2)
    )
How to search in a string containing words, three letter month and two digit year for the month and year and convert the

How to search in a string containing words, three letter month and two digit year for the month and year and convert the


By : user3150246
Date : March 29 2020, 07:55 AM
wish helps you Assuming that your month-year data always has the format MON-YY then you don't need to use (slow) regular expressions and can just use simple string functions to get the last 6 character sub-string and parse that as a date:
Oracle Setup:
code :
CREATE TABLE your_table( your_column ) AS
  SELECT 'ENGLISH.JOHN.BROWN.MAR.92' FROM DUAL UNION ALL
  SELECT 'GERMAN.TIM.OLIVER.JAN.95'  FROM DUAL;
SELECT TO_DATE( SUBSTR( your_column, -6 ), 'MON.RR' ) AS date_value
FROM   your_table;
| DATE_VALUE |
| :--------- |
| 01-MAR-92  |
| 01-JAN-95  |
SELECT TO_DATE( SUBSTR( your_column, INSTR( your_column, '.', -1, 2 ) + 1 ), 'MON.RR' )
         AS date_value
FROM   your_table;
SQL Server query to get total against each month of a year and return the year and month in date format not the string f

SQL Server query to get total against each month of a year and return the year and month in date format not the string f


By : user3412560
Date : March 29 2020, 07:55 AM
around this issue Dates have no formats, they are binary values, just like int or decimal or binary. DATE_FORMATION should be a date type, eg date, datetime or datetime2. If the column uses the correct type, the query can be simplified to just :
code :
select
    datefromparts(Year(DATE_FORMATION),MONTH(DATE_FORMATION),1) as DATE_FORMATION,  
    count([CO_ID]) as CO,
    sum([TOTAL_MEMBERS]) as Total_Members
from COCores
where 
    [DATE_FORMATION] as date) >= DATEFROMPARTS(Year(current_timestamp),1,1)
group by 
    YEAR(DATE_FORMATION),
    MONTH(DATE_FORMATION)
select
    Calendar.StartOfMonth,  
    count([CO_ID]) as CO,
    sum([TOTAL_MEMBERS]) as Total_Members
from COCores inner join Calendar on DATE_FORMATION=Calendar.date
where 
    Calendar.Year= Year(current_timestamp)
group by 
    StartOfMonth
Find dates inside range when date is stored as year, month and day separately

Find dates inside range when date is stored as year, month and day separately


By : Mr. Desk
Date : March 29 2020, 07:55 AM
it fixes the issue You might be interested in using DATEFROMPARTS ( year, month, day )
code :
SELECT * FROM DataTable M
WHERE DATEFROMPARTS(M.[Year], M.[Month], M.[Day]) between @StartDate and @EndDate
Related Posts Related Posts :
  • how to loop for division funciton in r
  • Why does ggplot not allow suppressing of messages generated by its geoms?
  • Download multiple excel files linked through urls in R
  • sparklyr : spark_apply function is not working in cluster mode
  • dplyr mutate - How do I pass one row as a function argument?
  • R selecting rows by conditions given in an external table
  • Native regex way to replace multiple leading chars with equal number spaces
  • stan - difficulty vectorizing
  • How to define a function that calls shiny functions?
  • How to count number of observations in a "n" dimensional range in R
  • Superimposing asymmetric t-distribution using ggplot2
  • Makefile to render all targets of all .Rmd files in directory
  • Authentication failure with rdrop2
  • DT data table display error
  • Issue when adding new rows (with nested dataframes within) to a dataframe
  • R-How to compare two dataframe and update list column value
  • Series vector for approximating pi
  • what is difference between "variance explained " in Random Forest and "merror" in XGBoost
  • R - Cast dataframe on unique rows - reshape2
  • ggplot2: plot correct proportions using geom_bar
  • Speedup query for R data.table - can this two-argument function be applied by group more quickly?
  • apply a function to several columns at once with mutate
  • R 'cowplot' neatly produce gridded plot with shared (common) legends and unique legends
  • Repeat R script for many times and save results to text file
  • How to negative lookbehind for special characters
  • data.table inner join produces error when no match is found
  • Create a new column base on existing column, but row above
  • Is there a way to visualize the process of source() in RStudio?
  • google places api consumes 10 request but I am doing only 1
  • Statistical mode of a categorical variable in R (using mlv)
  • Using for-loop to mutate a data.frame in r
  • Make plot with regression line for mixed model
  • Shortcut to select matces cases in R studio
  • vectoriced norm/matrix multiplication
  • Negative log10 transformation in R
  • Plot data with duplicate points
  • Visualizing crosstab tables with a plot in R - changing colours
  • How to manually modify automated numbers and labels in plot
  • How can I follow any redirections of a url in R?
  • Add jitter to box plot using markers in plotly
  • Adding an extra item to the legend
  • ggplot fills in data in the wrong order
  • Convert list to data frame
  • R: filtering by list(s) of strings and returning all results that start with the content of the lists
  • R:How to attach parts of a data frame with different headers and/or an overflowing piece of the dat frame
  • How to use 'par' for manipulating plot margins?
  • Can dplyr::case_when return mix of NAs and non-NAs?
  • Text preprocessing and topic modelling using text2vec package
  • Uploading multiple files in Shiny, process the files, rbind the results and return a download
  • R levelplot: color green-white-red (white on 0) according to one variable, but show the values of another variable
  • Why [i] doesn't point to the starting point in a vector
  • In R after generating a mvrnorm distribution, Y, what does Y[,1] do?
  • expand a data frame to have as many rows as range of two columns in original row
  • Getting started with R and CFA
  • Re order x-axis in ggplot so time goes from 12AM to 11PM in R
  • R - Automatically stack every nth column of a data frame and save them as new objects
  • How to format dplyr output in R into doubles (or other workable format)?
  • Dataframe to matrix conversion using tapply turns zeros to NAs
  • Smallest multiple of 1:20 - How can I make it quicker?
  • How to specify the size of a graph in ggplot2 independent of axis labels
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org